5 years, 8 months ago.

How can I get the implementations of ADC_VREF and ADC_TEMP?

How can I get the implementations of ADC_VREF and ADC_TEMP imported into the nRF51 library? These defines were used in the answer posted by os.mbed.com/users/rajhanssingh/ for the stm32l152re in os.mbed.com/questions/75910/How-to-get-the-value-of-inbuilt-vref-int/

Error: Identifier "ADC_VREF" is undefined in "shields/main.cpp", Line: 29, Col: 19 Error: Identifier "ADC_TEMP" is undefined in "shields/main.cpp", Line: 30, Col: 19

Steve

2 Answers

5 years, 8 months ago.

Hi Steve,
we cannot read ADC_VREF value directly on nRF51822.
So the following program measures VDD then you can compensate Vref value if you want to do it.

Import programBLE_Temp_Vdd_via_UART

Send VDD voltage data and chip temperature data via BLE UART Service. You can see the data on iPhone nRF Toolbox UART application.


Please see nRF51_Vdd.cpp line35 to line49.
Input voltage sets internal Vdd/3 (CPU power line voltage).
Reference voltage sets VBG/1 (internal reference voltage (Voltage Band Gap reference) = 1.2V +/-1.2%).
Get 10bit ADC result as value name "wrk".
Then VDD = (wrk/ 1024) * 1.2 * 3.0.
If your VDD measurement value (by DVM) and above VDD are different, you can compensate 1.2V(VBG).

Temperature measurement, you can use SoftDevice function.
Please see main.cpp line120,121.

Accepted Answer

Thanks Kenji! I am sure I would never have found the sd_temp_get() function without help... where does one find the Mbed functions and/or SoftDevices available for a system peripheral? I am only slowly getting any answers from the Mbed documentation, which seems like more of a reference guide for those who know already where everything is. I got lost in the SDK versions for the several nRF51 and nRF52 devices... how does one keep them sorted? Is there a forum discussion on the docs?

posted by Steve Wald 09 Aug 2018
5 years, 8 months ago.

Hi Steve,

Are you asking about internal ADC inside the nRF51? If you look in the mbed-os libary, I believe most STM boards have ADC_VREF and ADC_TEMP as pin names to the internal ADCs. I don't believe the nRF51 has internal ADC channels therefore they produce an undefined error. Let us know if you have any more questions!

-Karen, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

I pretty much figured that there is no connection for these as inputs to the ADC after getting the errors and looking again at the part documentation, but had to try. I do have more questions about configuring the ADC. Thanks for the advice.

posted by Steve Wald 09 Aug 2018