Help needed regarding STM32L476 nucleo ADC

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks

First of all,i would like to appologize for starting a topic regarding stm32 in General electronics section/in AVR website...but i found no better match sad

 

* Locked because this is NOT STM_Land. Moderator *

 

 

Anyway,I am working with avrs for almost last 3 years and decided to buy a stm32 nucleo boards to have some fun with ARM and bought STM32L476G nucleo board.I started to write code in Keil MDK-5 with the help of Hal drivers from STM32Cube MX.I coded for some Blinky and Usart successfully.But as i moved to ADC,i faced a strange problem.From the board schematics,i found that the MCU is using 3v3 external Vref.I measured with a multimeter and found 3.29v.I then coded  a program to display the ADC read value via Usart.As the ADC of the STM32 is 12 bit,it should return 4095 while reading 3.3v.But whenever i am connecting PA0(Analog ADC pin 5/Pin no-14) to 3.3v,it is returning value between 4025 to 4028.I tried to average of 100 results but got same output.Also i tried with different clock speeds but had no luck.

My question is if the error(typically 1.63% to 1.71%) is normal or if my adc unit is faulty or am i missing something????I found very little help about L476G as the controller is very new.Please reply guys...   

Last Edited: Sat. Mar 19, 2016 - 06:22 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try http://stm32duino.com/ while this is focused on STM32F103 and the Maple Arduino libraries, there is some crossover to other lines.  Otherwise you probably will have better luck with the mbed forums.

 

Some time ago I setup an environment using the STM32Cube tool and the Arduino IDE.  https://github.com/sheepdoll/HALMX_Arduino_STM32.git This was a quick and dirty way for me to access the HAL setup code through the Cube tool.  The alternative is to use Eclipse and the OpenSTM32 toolchain from AC6.     I wrote this because the members on the ST forums kept saying RTFM.   Well I have been reading the Manual for the last 6 months or so,and I still resort to trial and error programming.  ADC is something I want to get working soon.  At least with the HAL abstraction it looks straightforward.  The downside it that ST seems to be more interested in marketing checkboxes, than in practical examples.    I have about a dozen or so ST32 dev kits.  Each one is slightly different than the other.   Probably why ST came up with the Cube tool that helps set up the various input modes and pin configurations.   Contrast this with most of the online ST32 examples use the now deprecated and non open source "Standard Peripheral Libraries."

 

The real issue, that I have mentioned on the STM32duino forums is that to make libraries work, one is in effect writing a AVRMega328 emulator in Arm.  So it is not surprising when the results differ between what an atmel ADC reads and what the ST32 ADC reads.    There is also the difference between running the MCU from 5 volts and 3.3V    As for things like 0.01v  I doubt my meters are that accurate.  When I do use ADC, I tend to calibrate it to the HW. 

 

The remaining thing to try is running the code on a different (identical) setup.  These things are cheap so there is really no excuse not to have a few boards around anyway.

 

Last Edited: Fri. Mar 18, 2016 - 09:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can help you but AVRFreaks.net isn't for ST products. then please ask your question here:

 

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx

 

Good luck

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

Topic locked