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, 5 months ago.
I can't get the Inputs working!
Hey, i got a Data Logger working on the STM32F401. Logging the AnalogIn Voltage. Now i just wanted to put the code on the EFM32 STK3700. So i connected the wiper of my Potentiometer to PD3 and the other from 3.3 to GND. In the code i just changed the AnalogIn-Line to AnalogIn value(PD3). Now the logged Voltage i got over the serial port is always 0V, however the potentiometer is turned. Do i have to add aditional config lines to get a value from the AnalogIns?
Question relating to:
2 Answers
9 years, 5 months ago.
I'm afraid I can't replicate this issue.
The following code worked just fine for me:
#include "mbed.h" //using PD3, 3.3V and GND AnalogIn input(PD3); LowPowerTicker tick; volatile bool update = false; float value; void updateValue(void) { value = input; update = true; } int main(void) { tick.attach(updateValue, 1.0f); while(true){ sleep(); if(update){ update = false; printf("%f\n",value); } } }
This outputted values between 0.00000 and 0.99977 over serial, once every second.
Edit: I also tried the code you posted, and it worked just fine out of the box. Are you certain you connected the pins correctly?
Yes! Pins are correctly connected. I think I got problems with ESD here and destroyed the A/D-Converter carelessly. I looked up the schematics and saw that there are no limitations between the input connectors and the mcu. I can't figure out any other reason. But thanks for your help :)
Edit: Your Code also doesn't work here. I also checkd the Voltage on the Input-Connector. There should be definetely a voltage. Not 0 V!
posted by 29 Jun 2015
It may help if you said what code you were using.
posted by Andy A 29 Jun 2015It's based on the AnalogValue Example on the STM32f401.
AnalogValue