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

AnalogIn Read giving incorrect voltages L476RG

22 Mar 2016

Anyone tried the example code for analog input read - on L476RG?

Scale of voltage readings is way off (code reports 51 Volts!).

http://www.emcu.it/NUCLEOevaBoards/mBed/QSG-Mbed-Library.pdf

I'm no expert but the code above seems to expect analog_value.read_u16() to be in the range 0 - 4095 (12bit)... ...it actually seems to range 0 - 65535. Is this just a question of where the ADC's 12 bits gets placed in the 16 bit uint_16?

I've tested shifting the ADC read to the right 4 bits and it seems to work with this !!correction!! : Result_V = ((MinStepRes * meas))/ ( !! 0x10 * !! 1000);

21 Dec 2016

The L476 has hardware oversampling on the ADC that can be configured to 16bits.

It would seem that your ADC was configured to this 16bit mode and that is why you are receiving a value from 0 to 65535.

Shifting to the right is one way of fixing this and is essentially equivalent of averaging multiple values which can help you reduce noise, however you may find this is also taking a lot longer than it would if you were to just run the ADC in 12bit mode.

You need to log in to post a reply