cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7B3I-DK Crosstalk on Analog Channels - Chip Temperature Sensor

Garnett.Robert
Senior III

Hi,

I am using four inputs on ADC1:

    /**ADC1 GPIO Configuration
    PA4     ------> ADC1_INP18
    PA0_C   ------> ADC1_INP0
    PB0     ------> ADC1_INP9
    PA1_C   ------> ADC1_INP1

and 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.

5 REPLIES 5
Amel NASRI
ST Employee

Hi @Garnett.Robert​ ,

Here some initial questions before trying to do some tests on my side:

  • keeping ADC1_INP18 on PA4, do you confirm that there is no issue if only ADC2_INP18 is not used?
  • is that possible for you to reduce code and hardware setup to use only ADC1_INP18 and ADC2_INP18?
  • do you confirm that other ADC1 channels behave properly?

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Uwe Bonnes
Principal III

Make sampling time as long as possible.

Garnett.Robert
Senior III

I played around with the sampling time, but it didn't fix the problem - see my reply to Amel.

Hi Amel,

I purchased another couple of the STM32H7B3I-DK Disco boards and wrote a test program to try various input combinations t get to see if the problem was due to a damaged board. It turns out it was not. The same behaviour is exhibited by both of the new boards.

I have attached my test program and a spread sheet of the results to this post.

TEST RESULTS

ADC Setup:

SystemCoreClock    280

ADC Clock PLL2P    200

hadc1.Init.ClockPrescaler    ADC_CLOCK_ASYNC_DIV8

hadc1.Init.ClockPrescaler    ADC_CLOCK_ASYNC_DIV8

Sample Clock Tim15    0.025

sConfig.SamplingTime    ADC_SAMPLETIME_810CYCLES_5 (ALL Inputs)

Essentially the issue only occurs when scanning more than one input on ADC1 (In addition to ADC1 IP18) and only occurs if ADC 2 is initialised to read the INP18 Temp sensor input. Whether ADC 2 is started or not makes no difference. The incorrect reading occurs in both cases.

The test voltage sources were set to 3.00 Volt with 10 turn 10 kOhm pots and have an internal resistance of ~1.1 kOhm with a 450 uF aluminium electrolytic capacitor in parallel with the output. The voltage source for the pots was 3.35 Volt.

Drawing attached.

The other issue I came across was when I set up the Digital Temperature sensor I found it was giving readings about 10 degrees celcius higher than the ADC 2 IP 18 Temperature sensor. The ambient temperature was ~24 deg C.

TEST PROGRAM DETAILS

The test program runs both ADC1 and ADC 2 independently in DMA Circular mode. DMA Interrupts are disabled as they are not required. Thus the ADC's run independent of software once started and are asynchronous with the software.

I am using FreeRTOS and have a monitor Task that reads the values from the ADC DMA memory and coverts the values to volts or temperature. The monitor task runs every 250 ms.

I also have a second task that runs the DTS which converts the reading to float and puts it in a global CPU_Temp_C.

The various input cofigurations tested are st in adc.h. viz:

#define CPU_TEMPERATURE_ENABLE  1
#define ADC_1_ENABLE 			    1
#define ADC_2_ENABLE 			    1
 
#define ADC_1_RUN	 			    1
#define ADC_2_RUN	 			    1
 
#define EXCLUSIVE_INP18		             0

Setting then recompiling the program allows the testing of the various input configurations. The meaningful combinations of these that were tested are shown in the spread sheet.

Please have a look at my program and the results.

I have not thoroughly tested the other inputs, but they appeared to be OK. I suspect that the VRefInt and VBat may have the same issues, but there isn't any access to the respective input pins on AC 1 on the Tiny Shark so I cannot be certain of this.

I'm sorry I couldn't get back to you earlier, beacuse I had to get new boards and am trying to complete my current project.

Best regards

Rob

Screen Shots:

0693W00000LyAmEQAV.png