cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L562VET6Q Opamp plus ADC reading invalid value when pin in alternate function mode

patrickwright
Associate II

Our product uses an STM32L562VET6Q MCU.  We are using an ADC to measure current via a 1ohm resistor.  Because the currents are relatively small, I want to use the internal opamp in PGA mode to double the input signal before it is send to the ADC.  I have connected my input to PA0 which is OPAMP1_VINP.  According to the user manual, the output of OPAMP1 is connected to ADC1 Channel  8 (ADC12_IN8).

After getting everything configured, I noticed that my ADC was reading a constant, incorrect value when another part of the system was running, but was reading good values when that part of the system was disabled.  I was able to narrow down that when the UART in that system is enable, the ADC+OPAMP is giving incorrect values.  I am using PA3 and PA2 for UART2.  Those pins are configured in Alternate Function mode (I verified via the debugger to make absolutely sure).  I noted that PA3 is also ADC12_IN8/OPAMP1_VOUT.  If I configure this pin into analog mode (and lift the pin so it is not connected to the UART line) my problem goes away.

This is very confusing to me, because, to my knowledge, if the pin is in alternate function mode, shouldn't it be muxed away from the analog circuitry?  However, it appears that this pin is having some effect upon the internal routing between the output of OPAMP1 and the input to the ADC.  Is someone able to provide a decently detailed block diagram/pseudo-schematic of this pin?

1 ACCEPTED SOLUTION

Accepted Solutions
raptorhal2
Lead

Table 193 in the Reference Manual says pin PA3 is connected to the OpAmp when the OpAmp is enabled. Presumably because output to something other than the ADC channel 8 is also a design feature.

Chose a different USART assignment.

View solution in original post

3 REPLIES 3
raptorhal2
Lead

Table 193 in the Reference Manual says pin PA3 is connected to the OpAmp when the OpAmp is enabled. Presumably because output to something other than the ADC channel 8 is also a design feature.

Chose a different USART assignment.

Okay, I read through that table when I was making performing my initial tests.  The wording was a bit vague, so I didn't realize the implication was the pin would fully be rerouted to the OPAMP.

patrickwright
Associate II

Perhaps the following figure from the reference manual also helps to illustrate the problem:

patrickwright_0-1699542473847.png

If this is accurate, it looks like the Analog signals are attached to the pin after all the port muxing/configuration of alternate functions.  Assuming the OPAMP output is connected to the highlighted Analog line (on the bottom right) this means that, no matter how the pin is configured, that signal will still find its way onto the line (and visa versa).