0

SAADC buffer convert fatal error

Adri gravatar image

asked 2017-08-11 14:24:31 +0200

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!

edit retag flag offensive close delete report spam

1 answer

Sort by ยป oldest newest most voted
0
AmbystomaLabs gravatar image

answered 2017-08-11 15:44:27 +0200

updated 2017-08-11 15:57:38 +0200

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.

https://devzone.nordicsemi.com/questi...

edit flag offensive delete publish link more

Comments

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!

Radiohead ( 2017-08-11 16:24:03 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-08-11 14:24:31 +0200

Seen: 25 times

Last updated: Aug 11