Go Down

Topic: Delay within an ISR??? (Read 676 times) previous topic - next topic

Duncan in Spain

Hi

I want to implement an ISR that performs a delay at the end before returning - to ensure that the remote IR triggering device has finished sending its codes (It repeats a variable mumber of times until it either receives a response from the controlled device - I am "sniffing the signal into that device - or it times-out after about 1.5 seconds).

The ISR will create a "windmill effect" with three concentric circles of twelve LEDS so I will need to implement delays with that as well.

I realise that "Delay" is unavailable during an ISR, so how do I achieve this?

I did think about disabling Interrupts at the start of the ISR, using "Delay" and then re-enabling interrupts but I don't know if that would work and I'm not sure I can work out how to do that

I also thought about polling the input pin, rather than using an interrupt, but as I am looking at a 38KHz encoded signal stream it could, in theory, miss the state change every time - so I thought I would use either an edge or a state-change interrupt (I've never used them before).

Simple (even if "belt and braces") responses preferred as I am still a novice with Arduino and I don't think like a programmer.

Thanks for any help...
I used to be sure of things until I read Heisenberg...

wanderson

First, delays are not a good idea in an ISR; however, if you really want to do so you can implement the c code for such a delay in your ISR.  Take a look at util/delay.c & .h in your avr-libc code (it comes with the arduino).
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

Graynomad

At 38kHz you are talking about 13uS for a pulse you won't miss a state change in a tight polling loop.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Duncan in Spain

Thanks guys

I went for polling the input and it works fine...
I used to be sure of things until I read Heisenberg...

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy