9 years, 9 months ago.

Problem with AnalogIn on STM32L053R8 board

Hello, Whenever i call the analogin class to create new analog pin - the board will hang. I have already tried other revisions of the embed library as suggested in other answers to questions and nothing helps!

for example:

AnalogIn analogValue(A0);

This line of code is enough to cause the program to hang.

Any suggestions?

Question relating to:

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

I think you should use PA_0 instead as A0 is used for Digital_in_out classes

posted by MINZHE TAN 12 Mar 2015

4 Answers

9 years, 8 months ago.

Hello again everyone,

I think I've found a workaround. Someone commented on one of the related posts that the issue was to do with the HSI, I guessed that it may be a time-related problem. I introduced a 1 microsecond wait before constructing the AnalogIn object, and that stops the program from hanging and allows me to sample from the ADC.

/media/uploads/certifiedwaif/main.cpp

This gives me the following output from the serial port: Hello World ! This program runs since 1 seconds. Read 1536 from ADC This program runs since 2 seconds. Read 1472 from ADC This program runs since 3 seconds. Read 1568 from ADC ...

I hope that helps.

Accepted Answer

Confirmed to be working. Thanks!

posted by Hadar Matan 14 Mar 2015

Notice mbed v96 is working now!

posted by Jerry Zhang 19 Mar 2015

thanks for your answer!

posted by 綦 孝茵 09 Apr 2015
9 years, 8 months ago.

I am having same problem as well.....

9 years, 8 months ago.

You should use AnalogIn analogValue(PA_0); instead, the A0 should be used in Digital class such as DigitalIn in(A0);or DigitalOut out(A0);

A0 and PA_0 are exactly the same for the program. Just different names of writing the same value.

posted by Erik - 12 Mar 2015

I'm afraid @Erik Olieman is right, changing AnalogIn analogValue(A0) to AnalogIn analogValue(PA_0) does not change the fact that the board hangs as soon as the AnalogIn object is constructed.

This is very disappointing as I bought the board specifically because it has 12 bit ADC and DAC. I hope it's fixed soon.

posted by Mark Greenaway 13 Mar 2015
9 years, 8 months ago.

I use Nucleo L053R8,and have the same problem.When i try to use the PC_8,it will return "pinmap not found for peripheral" .But use any ADC pin to define: AnalogIn ain(ADC_PIN),the system will hang.

Notice that PC_8 is not support for AnalogIn class

posted by MINZHE TAN 12 Mar 2015

There was a problem with the HAL_Delay function called in the HAL_adc_init when used in mbed. A new STM32Cube driver version has been released in mbed v96 and everything must be OK now.

posted by bco stm 18 Mar 2015

Assigned to bco stm 9 years, 8 months ago.

This means that the question has been accepted and is being worked on.