STM32G474 no ADC input and no timer input from external signals | pulses etc

Post here first, or if you can't find a relevant section!
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by meier13 »

Hello,

this is my first post and questions, questions, questions.

If have bild some measurement systems with the f103 and the f407 and all worked fine. Now i have build an upgrade with the G474 to get a "one size fits all" system. We have not the time to develop for each application new boards.

But now i have some trouble with the analog and timer input. It seems that the physical input pin is not connected to the function block (ADC, TIMER).

After long time google searching i found a hint and now it is running, but i don't understand why.

flowmeter_1->setMode(1, TIMER_INPUT_CAPTURE_RISING,PB4); works with the f103 (tested today) and F407 (as i remember) but not with G474
flowmeter_1->setMode(1, TIMER_INPUT_CAPTURE_RISING,PB_4); works with the G474

analogRead(PA0) works with the f103 (tested today) and F407 (as i remember) but not with G474
analogRead(PA_0) works with the G474

Why for example PA0 and PA_0?

How do i choose which ADC for conversion?
Thats for now.

Thank in advance.
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by fpiSTM »

PA_0 is the PinName and could not be used for Arduino API like analogRead which required pin number like PA0.

In this case PA_0 is equal to 0x00 which leads to analogRead(0) or analogRead(A0). For Nucleo G474RE, A0 is defined to be PA0.
I've tested and it works as expected.
Same for timer. PB_4 is in fact equal to 20 which in fact is PA15 for the Nucleo G474RE using TIM2_CH1.

Further digging, I guess you used the generic variant, in that case the PinName PB_4 equals to the pin number PB4 --> 20.
And the same for PA_0 and PA0.
I've also tested with the generic variant and it works.

Could you describe your setup? IDE version? Core version? options,...
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by meier13 »

Thank you for the fast replay.
I am using Arduino 1.8.18 and a generic STM32G474CET. As i know there is no (ST-) commercial board. The core version is

Using board 'GenG4' from platform in folder: C:\...Arduino15\packages\STMicroelectronics\hardware\stm32\2.3.0
Using core 'arduino' from platform in folder: C:\...Arduino15\packages\STMicroelectronics\hardware\stm32\2.3.0
setup-arduino.png
setup-arduino.png (28.15 KiB) Viewed 869 times

Pinnumber, pinname and the numbering of Arduino ist confusing. Until now i thought that i use the " Label of the pins" in the data sheet.

In this case PB4 and PB6 for the t/c 3 and 4 and in1 and PA0 to PA3 for ADC1 input 1 to 4, but it does not work with this G474
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by fpiSTM »

G474RE or CE are pretty much the same.
I flash the binary generated for G474CE on my G474RE and it works.
What is strange is, as explained, in your case using PA_0 or PA0 result in the same call of analogRead(0).
Same for PB_4 and PB4 which are both equal to 20 so I don't understand what can be the issue.
The only thing I can told you is to update to latest core version 2.4.0.
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by meier13 »

Yes ce and re are quite the same for internal use but maybe some pins have different mappings but it seems working for you.

Meanwhile i have seen that there is a new version. i will test it and report.
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by fpiSTM »

meier13 wrote: Thu Feb 02, 2023 2:19 pm Yes ce and re are quite the same for internal use but maybe some pins have different mappings but it seems working for you.
In this case PA9/PA10 and PB6/PB7 are linked to USART1 instance for both. So it is ok.
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by meier13 »

so all updated, same result, but it seems, that other used modules are influence the configuration.

I have tried it with the full code which includes webserver over w5500 spi modul, Oled over I2C and some other pins. That works with the old CPU but not with G474. using only the counter it works with the cpu. Analog sometimes yes, sometimes no.

I have to stop it for a day or until monday, because i gegan to make some mistakes by conecting/disconnecting the voltage and the pulses from the frequency generator and swapping between the different testcodes. I made it too often last 2 days.
On Monday i will check all again from scatch to avoid any made mistake.

Here 2 fotos to schow on what i am working.
g474-2.jpg
g474-2.jpg (93.56 KiB) Viewed 853 times
g474-1.jpg
g474-1.jpg (80.04 KiB) Viewed 853 times
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by fpiSTM »

It seems we do not have all information ;)
You should try first a basic example like analogReadSerial.ino.
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by meier13 »

So the first thing with the ADC is solved.
Today i began from scratch testing the ADC. Sometime it was working randomly, but after a power off the same configuration did not work. When it was on for a while it began to work :). Sounds like charging or leakage current.
The G474 has an internal reference voltage with 2.048, 2.50 and 2.9V which i want to use. I have not seen that the external reference is the default setting. My external refence pin was floating because i could not find out while routing the PCB if the external pin is disconnected or i have to leave the pin floating.

Bridging the pin to VCC was the solution. :lol: Stupid mistake, it happens when there are long intervals between the time working on it.

Thank you fpiSTM. You helped me to proof that my code is ok and the definitions of the CPU are ok. So it must be my board.

Next check will be the timer/counter input. The rest is working fine.
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G474 no ADC input and no timer input from external signals | pulses etc

Post by fpiSTM »

Great! Thanks for the feedback.
Post Reply

Return to “General discussion”