STM32G474RE ADC2 (PA1) Produces Unexpected ADC Readings

Hello,
I am currently trying to perform code generation on an STM32G474RE using a simple circuit model as shown in Fig. 1. However, when I attempt to read the output value from ADC2 channel 2 (PA1), the measured result shown in Fig. 2 is different from the expected result in Fig. 3.
I am not sure whether the ADC2 channel 2 (PA1) pin on my STM32 is damaged or if there is an error in my configuration. Could you help me identify the possible cause of this issue?

Fig 1. Simple Model

Fig 2. The Value of ADC in PA1


Fig 3. The Correct Value of ADC

Hi rizalsaputra,

That is quite strange. Could you confirm that both the ADC input and DAC output have the scaling set to 1 and the offset set to 0? Also, just to make sure, are the physical pins externally shorted together with a wire?

It would also be helpful if you could share the model file that reproduces the issue so we can better understand what is happening.

Finally, if you move the ADC input to a different port, do you still see the same issue? This would help determine whether the original pin may be damaged, as you suggested.

Yes, the ADC input and DAC output have been configured with a scaling factor of 1 and an offset of 0. The physical connection has also been made by wiring pin PA4 (DAC output) to pin PA1 (ADC2 channel 2).
If I move the ADC input to another pin, for example PA0 (ADC1 channel 1), the measured result matches the expected output as shown in Fig. 3.
Here is the model I am using.

simple_demo_model.plecs (168.4 KB)

Hello - that you for providing the PLECS model! I am not able to reproduce the issue and obtain the attached result, which corresponds to the expected result. Would you be able to double-check the full setup including pin connections? It is very easy for mixups to happen somewhere along the way. Alternatively, would you be able to test your model with a different Nucleo board?

Thank you for your reply, but i am sure that my set up connections is true. I am sorry, i can’t able to test model with different Nucleo board.

Here my setup:
(Pin PA4 and PA1 is short by jumper cable)

It looks like the orange wire correctly connects the ADC and the DAC. When I connect these pins, the target behaves as expected. What is the purpose of the other wires? How are you powering the board? For my successful test, I power the board using the USB cable.

Another cable is used for STM32 connection with RT Box for my open loop average inverter project.
I power the board using the USB cable as shown in figure setup connection above.

Does the issue persist when the board is not connected to the RT Box? If the power supply is coming from the RT Box and the USB cable, it might be possible that the ADC voltage reference is initialized incorrectly (but I haven’t observed this on the STM32G474RE device). If this is the root cause, you could also try moving the jumper from 5V_STLK to E5V.

Yes, this issues occurs when STM32 is not connected to the RT Box