Ian_Hurlock Posted June 28, 2003 Report Share Posted June 28, 2003 Anyone got any ideas for adding code to MIOS to enable the leds to flash when selected ?Ian Quote Link to comment Share on other sites More sharing options...
LO Posted June 28, 2003 Report Share Posted June 28, 2003 try blinking ??? Quote Link to comment Share on other sites More sharing options...
Ian_Hurlock Posted June 28, 2003 Author Report Share Posted June 28, 2003 Don't give up ye day job........ya monkey ;) Quote Link to comment Share on other sites More sharing options...
Rowan Posted June 28, 2003 Report Share Posted June 28, 2003 HiGood idea Ian. I was thinking about buying some flashing LED, but this sounds like a much cheaper way of achiving the same result.Rowan Quote Link to comment Share on other sites More sharing options...
pilo Posted June 28, 2003 Report Share Posted June 28, 2003 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 Quote Link to comment Share on other sites More sharing options...
pay_c Posted June 28, 2003 Report Share Posted June 28, 2003 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? Quote Link to comment Share on other sites More sharing options...
Ian_Hurlock Posted June 28, 2003 Author Report Share Posted June 28, 2003 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 miosIan Quote Link to comment Share on other sites More sharing options...
pilo Posted June 29, 2003 Report Share Posted June 29, 2003 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 ??? Quote Link to comment Share on other sites More sharing options...
TK. Posted June 29, 2003 Report Share Posted June 29, 2003 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 cycleDOUT_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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.