2023-04-24 01:26 PM - edited 2023-11-20 07:16 AM
I have successfully configured the adc watchdog. But i am a bit dissapointed of the accuracy. I set the bounds to 1000 and 3000, but when i read the values of the adc from the watchdog interrupt, i get also values from within the window (up to 1025/2975).
The signal is 10Hz Triangular. I already measured the time from beeing outside of the window until the interrupt is executed (4us). So there is no timing issue.
In the manual it says:
The analog watchdog feature allows very precise monitoring of the converted voltage of one, some or all selected channels. An interrupt is generated when the converted voltage is outside the programmed thresholds.
25 of 4096 at 3.3V is 20mV... I would not call that very precise, not even precise....
Is it a safety margin?
I could compensate this, but i wonder if it could change somehow (temperature etc.)?
I made a diagram, to visualize it and added a cap to smooth out the signal:
x-axis shows the value from the ADC, and the y-axis is the number of measures values. The window has been changed to 3000/3200.
Solved! Go to Solution.
2023-05-04 12:53 PM
I just found out, that the ADC watchdog only works as expected, when the adc runs at 2Mhz or lower! It may work slightly above that... i havent tried.
2023-05-07 11:30 AM
I think i found the problem (probably, as there is a lot of code just for the ADC) in my case: The EOC interrupt cleared the EOC flag, which itself reset the preservation of the ADC dataregister. And i thought this would only happen when i would read the dataregister.
I found this int the datasheet, which is not clearly stating this:
"EOC flag is cleared by the software either by writing 1 to it or by reading ADCx_DR."
At the relevant point in the datasheet there is no information about this:
It is possible to configure if data is preserved or overwritten when an overrun event occurs
by programming the control bit OVRMOD:
• OVRMOD=0: The overrun event preserves the data register from being overrun: the
old data is maintained and the new conversion is discarded and lost. If OVR remains at
1, any further conversions will occur but the result data will be also discarded.