Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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:
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.
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 12 Mar 2015I'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 13 Mar 20159 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.
Assigned to
9 years, 8 months ago.This means that the question has been accepted and is being worked on.
I think you should use PA_0 instead as A0 is used for Digital_in_out classes
posted by MINZHE TAN 12 Mar 2015