Reputation: 1143
I have custom board on which I can upload my code generated from platformio and as board bluepill_f103c8
. And I can make led blink etc. but when I want to do analogRead it always returns 0.
I'm trying to read from PA8
pin.
In my setup I put that pin as INPUT_ANALOG, do I need to do something else in order to get the reading?
Voltage that's on pin is about 0.25V that I'm trying to read.
Upvotes: 2
Views: 3199
Reputation: 689
According to STM32F103 Datasheet, page 34, any of 3 onboard ADCs simply do not have the ability to connect to PA8. PA8 can only work as simple GPIO (default, reads only 0 and 1), or as USART1_CK, TIM1_CH1, MCO in alternative configuration. Arduino can use it as PWM output, or software USART, but there is no way to get analog reading from it. If you really need to read analog voltage coming to that line, you would have to modify your board and solder PA8 to one of PA0..PA7, PB0..PB1, PC0..PC5 and re-configure ADC to read from that line.
@TonoNam, regarding your problem: unless PA1 is permanently damaged, it is fully capable of working with ADC, so there is something wrong with initialization or reading procedure.
Upvotes: 2
Reputation: 4463
Reference the pinout diagram here https://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif
analogRead
will only work with the pins which have associated ADC channels.
So this is PA0
through PA7
, and then PB0
and PB1
, so I guess this is your issue.
Looks like PA8
is a PWM output.
Upvotes: 1