Rennie Johnson
Member
I'm doing continuous timed LED strobing for film scanning using Teensy 4.1. Depending on film speed, the exposure function will be called between 2 and 24 times per second. The exposure time is usually between 100us and 1ms. This is the function that is called each time an exposure is triggered:
I'd like to add two quadrature encoder inputs on pins D0 and D1 that will trigger external interrupt functions at up to 24Khz each. The interrupts will maintain the quadrature counts and call the StartTimer() function when the next film frame to be captured has reached the correct position. The interrupt function for each encoder channel looks like this:
In this scenario, the hardware interrupts will be called multiple times during each execution of the StartTimer() function. However, StartTimer() will always complete before it is called again. My question is:
Will the delayMicroseconds() call in StartTimer() lose accuracy because of the interrupts being called during its execution?
Code:
void StartTimer()
{
digitalWriteFast(PIN_SHUTTER_OUT, LOW);
delayMicroseconds(gTimerInterval);
digitalWriteFast(PIN_SHUTTER_OUT, HIGH);
}
I'd like to add two quadrature encoder inputs on pins D0 and D1 that will trigger external interrupt functions at up to 24Khz each. The interrupts will maintain the quadrature counts and call the StartTimer() function when the next film frame to be captured has reached the correct position. The interrupt function for each encoder channel looks like this:
Code:
void GateInterruptA()
{
if (digitalRead(TRANSPORT_PIN_TRIGGER_SELECT_A_IN) == HIGH)
{
UpdateQuadratureCountA_HIGH();
if (g_audioSample_Quad_A__High_Enabled)
TriggerAudioSample();
}
else
{
UpdateQuadratureCountA_LOW();
if (g_audioSample_Quad_A__Low_Enabled)
TriggerAudioSample();
}
if((m_currentEncoderCount % m_encoderCountsPerFrame) == m_totalFramingOffset)
{
if(m_liveViewEnabled)
StartTimer();
else
{
if(m_programmedCaptureEnabled)
{
if((m_currentFrameCount<=m_programmedCaptureEndFrame)&&(m_currentFrameCount>=m_programmedCaptureStartFrame))
StartTimer();
}
}
}
In this scenario, the hardware interrupts will be called multiple times during each execution of the StartTimer() function. However, StartTimer() will always complete before it is called again. My question is:
Will the delayMicroseconds() call in StartTimer() lose accuracy because of the interrupts being called during its execution?