Pages: [1]   Go Down
Author Topic: Delay within an ISR???  (Read 504 times)
0 Members and 1 Guest are viewing this topic.
L'Escala, Girona
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

I used to be sure of things until I read Heisenberg...

Dallas, Texas
Offline Offline
God Member
*****
Karma: 31
Posts: 887
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 127
Posts: 8522
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

L'Escala, Girona
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys

I went for polling the input and it works fine...
Logged

I used to be sure of things until I read Heisenberg...

Pages: [1]   Go Up
Jump to: