This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SDK_LOG_ENABLED causes saadc channels to shift.

So we have the SAADC configured to read using timer attached to ppi. We read from 5 adc channels. If we set NRF_LOG_ENABLED to 1 in sdk_config.h all the channels read fine. However, if we set NRF_LOG_ENABLED to 0, the values in the adc channels shift by 2 channels, eg channel 1 is now the values of channel 4.

I've seen posts saying saadc channels can get shifted if the saadc isn't uninitialized properly between reads. However, when we first started using the saadc, we ran into that issue and fixed our uninitialization. The other strange part, is that with the NRF_LOG_ENABLED issue I'm seeing, the very first read from the saadc is shifted, implying it isn't an issue with uninitialization, but rather the initialization itself. 

What is strange is that the nrf logger would somehow be causing this issue. I can't seem to find any posts with the same issue, but it has such a strange cause I'm also having trouble phrasing my search in a way that brings up relevant results.

Any thoughts on what/why the logger module is shifting the saadc channels?

  • Hi Scott,

    This does look strange and might be due to the "errata". According to the errata workaround, you may have to trigger a STOP explicitly and wait for the stopped event.

    Regards,

    Priyanka

  • Ok what is the best way to trigger a STOP event with the sdk? Is it nrf_drv_saadc_abort, or nrf_drv_saadc_unint, and will uninit remove the calibration that just took place?

  • Hi Scott,

    It would be better to STOP manually i.e.

    NRF_SAADC->EVENTS_STOPPED = 0;

    NRF_SAADC->TASKS_STOP = 1;

    while(NRF_SAADC->EVENTS_STOPPED==0);

    NRF_SAADC->EVENTS_STOPPED = 0;

    When using the uninit, it calls abort which in turn triggers STOP but only when the driver state is IDLE (and driver becomes IDLE only when the CALIBRATEDONE event is received)

    Regards,

    Priyanka

  • Tested it and running those lines after the CALIBRATEDONE event fires does fix the issue. I still find it strange that a brief delay fixes the issue also, but I guess that's what you get when you're working around an errata. Thanks for the help Priyanka!

Related