Hello!
It seems to me that GCC compiler optimization (-O3 -g3) somehow break the SAADC.
When enabling said optimizations the SAADC no longer gives me valid measurements (e.g. I have an expected ADC value of 1200 but when enabling optimizations I get a value of 3).
Here you can find my code that I am using to measure the SAADC
This code is responsible for measuring the analog inputs 4 and 5.
The issue occours on both inputs. The numerical example I have given above is for Input 5.
I am aware of Anomaly 86 (https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52832_Rev2%2FERR%2FnRF52832%2FRev2%2Flatest%2Fanomaly_832_86.html&cp=3_1_1_0_1_23)
To avoid this issue I have slightly modified the nrfx_saadc_abort function to remove as seen below.
This change allows me to use this function to stop the SAADC as described in the anomaly without having to write my own code and it works just as expected if I have optimizations disabled.
I have been able to disable optimizations for the nrfx_saadc.c file by adding "#pragma GCC optimize("O0")" to the start of the file. This makes the SAADC measurement work again but it just doesn't feel right.
Are you aware of this issue and do you have any suggestions on what I should do to fix it?
Regards
Michael