I'm using Joshua Austill's AD7606 library and he makes use of
when reading from theAD7606 in parallel.
In his basic example code he does the ADC read directly in the main loop. So the timing of the acquisition is dependent on the other logic in the loop, the more additional logic, the slower the acquistion speed.
To overcome this I tried to implement an
to sample every 10uS and pushing the samples into a ring-buffer to be dealt with in the main loop as I see fit.
When I put the ADC read into the ISR the code just freezes.
The
turns off interrupts, reads the ADC then turns them back on again.
Could this be why my code stalls?
Code:
noInterrupts()
In his basic example code he does the ADC read directly in the main loop. So the timing of the acquisition is dependent on the other logic in the loop, the more additional logic, the slower the acquistion speed.
To overcome this I tried to implement an
Code:
IntervalTimer
C++:
void samplingISR()
{
adc.getVoltages(voltageData);
// Check ring buffer has space
if(rb.bytesFree() >= sizeof(voltageData))
{
rb.write((const uint8_t*)&voltageData, sizeof(voltageData));
totalSamplesLogged++;
}
else
{
bufferOverflowed = true;
}
}
When I put the ADC read into the ISR the code just freezes.
The
Code:
getVoltages()
C++:
void AD7606p16_t4::getVoltages(float* voltages) {
if (lastIsrCall > 10) {
this->reset();
}
noInterrupts(); // Disable interrupts to ensure atomic read
for (uint8_t i = 0; i < 8; i++) {
voltages[i] = (instance->channels[i] * instance->vRef) / 65536.0f;
}
interrupts(); // Re-enable interrupts
}
Could this be why my code stalls?