How to deal with timing during noInterrupts()?

Status
Not open for further replies.

howiemnet

Active member
I'm titting about with a Canon EF lens, trying to control focus independently of the camera. Others have already done the hard lifting in terms of deciphering (most of) the protocol, and I'm able to use my Teensy to communicate with the lens and move it in and out.

The issue is: the Canon protocol needs precise timing, so the code I'm using has the critical bits of communication wrapped in

Code:
noInterrupts();

and

Code:
interrupts();

If I understand correctly, this affects timing functions (millis() etc) and comms. Fair enough: what I need to know is:

- How do I measure the time spent with interrupts disabled, so I've some idea of what I'm dealing with?

Then:

- If I use an intervalTimer to trigger my code every 25th of a second, but there are brief periods (say a few milliseconds) where interrupts are disabled, will my intervalTimer lose time cumulatively? (I'm not so worried about jitter - the intervalTimer function being called a little late - just whether this will add up over time)
- The UART uses an interrupt but has a buffer. AIUI it needs the interrupt to service the buffer; I'm only receiving single bytes at a time though. So does the UART need the interrupt in order to turn incoming bits into bytes, or does it only need it to handle the bytes? (In other words, will noInterrupts corrupt reception of even a single byte)?
 
Status
Not open for further replies.
Back
Top