Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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?

Posted

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 ???

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...