STM32H7B3I-DK Crosstalk on Analog Channels - Chip Temperature Sensor
- January 7, 2022
- 3 replies
- 2011 views
Hi,
I am using four inputs on ADC1:
/**ADC1 GPIO Configuration
PA4 ------> ADC1_INP18
PA0_C ------> ADC1_INP0
PB0 ------> ADC1_INP9
PA1_C ------> ADC1_INP1and six on ADC2:
/**ADC2 GPIO Configuration - Set in stm32h7xx_hal_msp.c */
PC4 ------> ADC2_INP4
PC2_C ------> ADC2_INP0
PC3_C ------> ADC2_INP1
/** Set in MX_ADC2_Init
ADC_CHANNEL_VBAT ------> ADC2_INP14
ADC_CHANNEL_TEMPSENSOR------> ADC2_INP18
ADC_CHANNEL_VREFINT------> ADC2_INP19 */I run both ADC's independently, with both driven by Timer 15 TRGO using DMA circular with no interrupts.
The problem I have is that ADC 1 Input 18 (PA4) reads incorrectly when the ADC2 Input 18 (Temperature sensor) is enabled.
PA4 is driven by a ST Micro LM135 absolute temperature sensor with the following circuit.
With the enclosure temperature connected to PA4 (Arduino A0). J4 Connects the LM135 temperature sensor.
With a temperature of 25 deg c there should be about 2.9 Volt however it is pulled down to 1.45 V. If the external circuit is removed and the PA4 pin is measured with a 10Mohm probe it floats at about 940 mV compared with the other Arduino Inputs which float at about 30 mV.
Solder bridge SB44 has been removed (STMOD-Pin13) and there is no camera connected.
When the ADC2 INP 18 Temp Sensor is left out of the mix, pin PA4 behaves as the other analogs, with a voltage of about 30 mV when floating and about 2.9 Volts with the temperature sensor circuit connected and with a sensor temperature of about 25 deg C.
Calculating the temperature with the Temp Sensor disabled gave 25.25 degrees which was spot on with a good thermometer.
I routinely use the temperature sensor in my projects, whenever I use analog inputs and have never come across this problem before. I thought perhaps that the output impedance of the temperature sensor is too high, but inspection of the data sheet shows it has an output impedance at ~dc of less than 1 ohm. With the 3.3 k Ohm pullup resistor and the ten volt supply I am putting about 2 mA through the LM135.
I have looked at AN2834 Application note How to get the best ADC accuracy
in STM32 microcontrollers, but I didn't see anything there that I might be doing wrong. I thought that each ADC had its own independent analogue input FET Mux so I can't see how the voltage on ADC2 IP8 can influence the voltage on the ADC1 INP18 pin. I also checked the chips errata doc, but nothing there either.
I checked the program to ensure that PA4 wasn't being modified by some other driver and found that it was always set to be and analog input with no pullup or other register being changed.
For the moment I have disabled the three internal measurements, but I would like to use the CPU Temperature Sensor as a backup to the Enclosure temperature.
Can anyone help or explain what's going on?
I have provided the ADC initialisation files main.c, stm32h7xx_hal_msp.c and freertos in a zip to give you the full story. I have also attached a PDF of the interface board that provides the circuitry for the analog and some other inputs. This board plugins directly into the Auduino socket of the main Discovery board.