7 years, 1 month ago.

Reference Material

Using the online MBED program there is a sample program. In the sample program "ADC internal temperature reading" there are three readings which are taken; one for internal temperature, one for internal voltage reference and one for battery.

AnalogIn adc_temp(ADC_TEMP); AnalogIn adc_vref(ADC_VREF); AnalogIn adc_vbat(ADC_VBAT);

Where on Earth can I find the reference values for ADC_TEMP, ADC_VREF and ADC_VBAT. The only header is #include "mbed.h". I do not find those values in there. In short, without the sample program, how would I know these items exist and what else is available.

  • I looked at the API, but fell short there as well.

Cheers Patrick

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L432KCU6 microcontroller.

3 Answers

7 years ago.

Take a look at the STM32L432KCU6 datasheet, section 3.15. You can find the calibration data by reading the memory addresses mentioned there (just create a pointer to the memory address and read it).

7 years ago.

If you're looking for the location where these defines are, they can be found via searching the repository such as this: https://github.com/ARMmbed/mbed-os/search?utf8=%E2%9C%93&q=ADC_VBAT&type=

If you want to learn more about the internal ADC values and how the references are done, follow the link from Jan above. That is a starting point but you really need to download the reference manual from ST and several of the application notes specific to how to read the internal ADC values. The reference manual walks through the details of how to use the ADC.

7 years ago.

Hi

You can find all available pins per peripheral in the PeripheralPins.c file. Each platform has its own file.

For example with the NUCLEO_L432K, you can access this file using mbed-dev library:
https://os.mbed.com/users/mbed_official/code/mbed-dev/file/79309dc6340a/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/TARGET_NUCLEO_L432KC/PeripheralPins.c/

The ADC Internal channels for example are described in the array:

const PinMap PinMap_ADC_Internal[] = {
    {ADC_TEMP, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)},
    {ADC_VREF, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0,  0, 0)},
    {ADC_VBAT, ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)},
    {NC,   NC,    0}
};

ADC_TEMP = channel 17, ADC_VREF = channel 0 and ADC_VBAT = channel 18.