analogRead and analogWrite troubles

Post here all questions related to STM32 core if you can't find a relevant section!
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: analogRead and analogWrite troubles

Post by fpiSTM »

Unfortunately, I have no more clue and I have no board with this MCU version to test.
Anyway, I see no reason it could not work.
You said you use PIO? Did you try with Arduino IDE?
kvv213
Posts: 38
Joined: Thu Dec 26, 2019 10:58 pm

Re: analogRead and analogWrite troubles

Post by kvv213 »

fpiSTM wrote: Fri Jan 03, 2020 1:27 pm Unfortunately, I have no more clue and I have no board with this MCU version to test.
Anyway, I see no reason it could not work.
You said you use PIO? Did you try with Arduino IDE?
Yes, at first I try with Arduino IDE, then try and debug under PIO.

I did one more experiment based on your amendment at GitHub. It seems that only one line is modified and one added at variant.cpp. I had an amendment of my local variant.cpp according to your amendments.

The result it the same - the board falls into infinite loop when try to analogRead(PA3).
kvv213
Posts: 38
Joined: Thu Dec 26, 2019 10:58 pm

Re: analogRead and analogWrite troubles

Post by kvv213 »

It seems that I've managed to find the problem with analogRead PA_3:
Annotation 2020-01-03 224859.png
Annotation 2020-01-03 224859.png (29.14 KiB) Viewed 8383 times
There can be a mistake at line 32. Instead of #ifdef #ifndef is used. So in that case PA_3 refers to ADC3 with 3rd channel. But the rest of refers to ADC1 and ADC2. So, I've commented 46 and added 47 with ADC2. After that it started to work.

That is in file PeripheralPins.c from variant. Should I suggest this as a change for commit or better correct #ifndef to #ifdef?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: analogRead and analogWrite troubles

Post by fpiSTM »

@kvv213

ADC3 should be functional, anyway as a workaround use the other.
I will have soon an STM32F103 based board with ADC3 then I will be able to test.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: analogRead and analogWrite troubles

Post by fpiSTM »

Well, I've reproduced the issue but I didn't have the solution.
Seems it is current to have issue with ADC3 on those series.
I raise an issue internal.
As a workaround simply use other ADC1 or 2.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: analogRead and analogWrite troubles

Post by stevestrong »

Libmaple core also has problem with ADC3, see: https://github.com/rogerclarkmelbourne/ ... -569238509
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: analogRead and analogWrite troubles

Post by fpiSTM »

Thanks to @ABOSTM issue with ADC3 is solved.

See https://github.com/stm32duino/Arduino_C ... 2/pull/910
myksj1105
Posts: 54
Joined: Sun Jun 18, 2023 11:35 am

Re: analogRead and analogWrite troubles

Post by myksj1105 »

@fpiSTM

viewtopic.php?p=12513#p12513

@fpiSTM

hello. Nice to meet you. PWM is not output.
help.
Post Reply

Return to “General discussion”