Anyone got any ideas for adding code to MIOS to enable the leds to flash when selected ?
Ian
Anyone got any ideas for adding code to MIOS to enable the leds to flash when selected ?
Ian
try blinking ???
Don’t give up ye day job…ya monkey ![]()
Hi
Good idea Ian. I was thinking about buying some flashing LED, but this sounds like a much cheaper way of achiving the same result.
Rowan
humm I think it will use more RAM… the simple is to make a flip-flop : a very easy schematic (2 NAND gate, a resistor and a caps) wich make blinking. But with Mios, you have to know when you light the led (or not), if : it has to be light… so you would have another bit of ram for each blinking led…
By the way, I think it’s AN EXCELLENT IDEA! so I’m going to try with as soon as I can!!! ;D
The problem is certainly not the RAM, I think. More the question is, if there’s a free timer Interrupt left in the PIC. And the only man who can answer this is… tadaaaaa… Thosrsten!!
So, what do you say, TK?
Do we need another interrupt
Can we just create a delay loop
I have done this with 16 f 84 but I don’t know how to get it into mios
Ian
timer interupt?
i don’t read the code to see how leds output are handle… but we just make it with a delay loop I think ???
Just use the USER_SR_Service_Prepare hook which is called periodically before the DOUT registers are loaded. The update frequency is 1 mS by default.
Example:
in app_defines.h following variables have to be assigned to free addresses:
DOUT_LED_CTR - a counter which will be incremented on every update cycle
DOUT_LED_FLASH_ENABLE - this register holds the information if the LED should flash or not. Up to 8 flags for 8 LEDs can be stored here, if more flags are required, an array should be used (not shown here)
Code (untested, but should work)
USER_SR_Service_Prepare
LED_FLASH_Handler
;; increment counter
incf DOUT_LED_CTR, F
;; skip next block if LED should not flash
IFCLR DOUT_LED_FLASH_ENABLE, 0, rgoto LED_FLASH_Handler_Skip0
;; skip if DOUT counter < 128 (bit #7 not set), this leads to a
;; flashing frequency of 1 / (128 * update_cycle) = 1 / (128 * 1 mS) = ca. 8 Hz
IFCLR DOUT_LED_CTR, 7, rgoto LED_FLASH_Handler_Skip0
;; get value of LED at DOUT #0
movlw 0x00
call MIOS_DOUT_PinGet
;; result in MIOS_PARAMETER1, invert it
comf MIOS_PARAMETER1, F
;; write back result to DOUT #0
movlw 0x00
call MIOS_DOUT_PinSet
LED_FLASH_Handler_Skip0
;; thats all
return
Best Regards, Thorsten.