Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUCLEO_L476RG: Measuring ADC_TEMP after using ADC_VREF in AnalogIn results in abnormal results #6398

Closed
maskedw opened this issue Mar 20, 2018 · 4 comments

Comments

@maskedw
Copy link

maskedw commented Mar 20, 2018

Description


Bug

Target
NUCLEO_L476RG

Toolchain:
GCC_ARM

Toolchain version:
arm-none-eabi-gcc 6.3.1

mbed-cli version:
1.2.2

mbed-os sha:
16bac10

Steps to reproduce
(Room temperature 23 ℃)

#include "mbed.h"

Serial pc(USBTX, USBRX);

int main()
{
    pc.baud(115200);
    while(1)
    {
        {
            AnalogIn adc_temp(ADC_TEMP);
            wait_ms(1000);
            int16_t temp12 = adc_temp.read_u16() >> 4;
            int32_t temp = __LL_ADC_CALC_TEMPERATURE(3300, temp12, LL_ADC_RESOLUTION_12B);
            printf("TMP: %d\n", temp);
        }
    }

    return 0;
}

This measured value is not as expected, but I have posted another issue. #6397

TMP: 30
#include "mbed.h"

Serial pc(USBTX, USBRX);

int main()
{
    pc.baud(115200);
    while(1)
    {
        {
            AnalogIn adc_vref(ADC_VREF);
            wait_ms(1000);
            uint16_t vref12 = adc_vref.read_u16() >> 4;
            int vref = (3.0f * (*VREFINT_CAL_ADDR) / vref12 * 1000);
            printf("AVDD: %d\n", vref);
        }

        {
            AnalogIn adc_temp(ADC_TEMP);
            wait_ms(1000);
            int16_t temp12 = adc_temp.read_u16() >> 4;
            int32_t temp = __LL_ADC_CALC_TEMPERATURE(3300, temp12, LL_ADC_RESOLUTION_12B);
            printf("TMP: %d\n", temp);
        }
    }

    return 0;
}

After measuring VREFINT, obviously an abnormal value will be returned.

TMP: -205
AVDD: 3306
@0xc0170
Copy link
Contributor

0xc0170 commented Mar 20, 2018

@ARMmbed/team-st-mcd Please review

@jeromecoutant
Copy link
Collaborator

Hi
Issue is confirmed. ADC driver team is contacted.
Thx

@jeromecoutant
Copy link
Collaborator

ST_INTERNAL_REF 45122

@maskedw
Copy link
Author

maskedw commented Mar 22, 2018

With #6412 change, we confirmed that both ADC_VREF and ADC_TEMP can be measured normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants