I'm been building a digital LockIn Amplifier. I am seeing very regular instability in the output of calls to e.g.
I have two ISRs which run when a digital line indicates a sample is ready or a SYNC signal is detected. These do not have floating point math in them. One merely records
I do not have a very solid hypothesis yet, but thoughts:
1) From what I gather there might be a floating point issue. I have not been able to figure out how to enable 'full fpu context saving' but from what I gather in other posts this might not be needed/already the case.
2) I wanted to enable 'fpu flush to zero' but am uncertain if the code below is correct to do this:
3) No pointers are used anywhere in the code except for the arrays which are sent to the CMSIS library. So it isn't clear to me how my code could be causing a corruption, let one one which is so regular.
Thank you very much for any thoughts
arm_biquad_cascade_df2T_f32
This occurs approximately every 1 million calls, or ADC samples collected. The magnitude of the instability has been found to related to the pretense of seemingly unrelated floating point operations elsewhere in the code.I have two ISRs which run when a digital line indicates a sample is ready or a SYNC signal is detected. These do not have floating point math in them. One merely records
ARM_DWT_CYCCNT
and the other collects a ADC sample by reading GPIO6_PSR
and timestamps this by again recording ARM_DWT_CYCCNT
I do not have a very solid hypothesis yet, but thoughts:
1) From what I gather there might be a floating point issue. I have not been able to figure out how to enable 'full fpu context saving' but from what I gather in other posts this might not be needed/already the case.
2) I wanted to enable 'fpu flush to zero' but am uncertain if the code below is correct to do this:
C:
uint32_t fpscr;
// Read FPSCR
__asm volatile ("VMRS %0, fpscr" : "=r" (fpscr));
// Set FTZ (bit 24) and DN (bit 25)
fpscr |= (1U << 24) | (1U << 25);
// Write back to FPSCR
__asm volatile ("VMSR fpscr, %0" : : "r" (fpscr));
// Data Synchronization Barrier and Instruction Synchronization Barrier
__DSB();
__ISB();
3) No pointers are used anywhere in the code except for the arrays which are sent to the CMSIS library. So it isn't clear to me how my code could be causing a corruption, let one one which is so regular.
Thank you very much for any thoughts