This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SAADC buffer convert fatal error

Hello,

For my project I need to measure the battery voltage while transmitting data to get a good indication of the battery capacity. I've found an old example (link text) that goes into detail on how to set the SAADC up where the ADC event can be manually triggered instead of using a timer and the PPI to start a conversion. The example also initializes and disables the ADC after the conversion is completed for lower power consumption.

However, I can't get it to initialize. When the function "nrf_drv_saadc_buffer_convert" is called, an fatal error occurs. I've checked with the SAADC example, but i can't find the reason the fatal error occurs. I've included "nrf_drv_saadc.h", "nrf_saadc.h" and enabled the SAADC in "sdk_config.h" with default settings in my project.

I could not get the code snippets to be displayed properly, so I've added it as a text file to this post: saadc.txt I usethe nRF52832 and SDK13.1 with Keil uVision 5.

Any help is greatly appreciated!

  • I noticed in your code you are measuring at AIN3. I assume you have an external voltage divider for a LiPo or something similar. Normally people ask about measuring nRF vdd.

    The only thing I see wrong in your code is how you read the SAADC buffer. Looks like you are just passing the pointer for it to the nrf log routine. Seems like you should pass the result from the nrf_drv_saadc_buffer_convert API. You will see the difference when you look at my code below.

    So...here is a link to a question where I detailed what we do for SAADC and battery voltage. Using PPI sounds complicated and unnecessary for battery monitoring. We just use the app timer and a software handler as you will see in the example. My example doesn't include SAADC calibration which came in later SDK's. I'm sure you can add calibration easily if you wish.

    devzone.nordicsemi.com/.../

  • Thanks for your link, I had not found that thread yet. I did manage to get the battery measurement working, but I don't know why it didn't work earlier, must have been some other piece of code.

    I'll take a look into the ADC calibration, whether it's usefull or not, but I doubt it is. Thank you for your time and answer!

Related