Author Topic: STM32F303 GPIO configured as Push pull affecting ADC readings  (Read 2418 times)

0 Members and 1 Guest are viewing this topic.

Offline WillHuangTopic starter

  • Contributor
  • Posts: 47
STM32F303 GPIO configured as Push pull affecting ADC readings
« on: February 25, 2017, 03:20:10 am »
Hi,
I'm using a STM32F303 (landing page: http://www.st.com/en/microcontrollers/stm32f303k8.html) for one of my project. I have PA0 configured as a GPIO output with push pull used to turn ON/OFF a BJT. I also have PA3 configured to use the ADC1 channel 4 module.

When I set PA0 high, the ADC readings increase by about 1.8V. When it is low, the readings are correct. Why does this happen? Externally, these two pins aren't connected directly to each other.

 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #1 on: February 25, 2017, 09:04:06 am »
1.8V is a lot. Either your circuit isn't working as expected, or the board is assembled poorly.
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4235
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #2 on: February 25, 2017, 09:27:19 am »
What actually happens to the voltage on PA3? Does it change at all when you change the level on PA0?

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21736
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #3 on: February 25, 2017, 11:38:39 am »
Is there any signal bounce on the pin?  (You may need a >200MHz oscilloscope and high impedance probe to verify this.)

Is there any noise coupling into the ADC pin?

Is the ADC signal source a high impedance?

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Throy

  • Regular Contributor
  • *
  • Posts: 53
  • Country: de
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #4 on: February 25, 2017, 12:44:26 pm »
I had a similar problem with a STM32F072.  I had connected one pin that can also be used as an ADC to a 5V transceiver thinking that the pin was 5V tolerant.  Obviously wasn't....  As a quick fix I was able to put current limiting resistor between the pin and the transceiver.  In the next board rev, I relocated the transceiver to a different pin.

Are you using a PNP and if so what is the voltage at the emitter?
« Last Edit: February 25, 2017, 12:46:46 pm by Throy »
 

Offline WillHuangTopic starter

  • Contributor
  • Posts: 47
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #5 on: February 26, 2017, 12:14:41 am »
1.8V is a lot. Either your circuit isn't working as expected, or the board is assembled poorly.
Sorry, it wasn't 1.8V. 1.8V is the reading I show on my LCD after multiplying it by a factor. The actual reading would be about 50mV.

What actually happens to the voltage on PA3? Does it change at all when you change the level on PA0?
When I change the level of PA0 to LOW, PA3 measure fines. If i were to set PA0 to high, I get an increased reading on PA3.

Is there any signal bounce on the pin?  (You may need a >200MHz oscilloscope and high impedance probe to verify this.)

Is there any noise coupling into the ADC pin?

Is the ADC signal source a high impedance?

Tim
ADC is being driven by a buffered op amp, followed by a RC network. I don't see any noise on the scope either.

I had a similar problem with a STM32F072.  I had connected one pin that can also be used as an ADC to a 5V transceiver thinking that the pin was 5V tolerant.  Obviously wasn't....  As a quick fix I was able to put current limiting resistor between the pin and the transceiver.  In the next board rev, I relocated the transceiver to a different pin.

Are you using a PNP and if so what is the voltage at the emitter?
I was using an NPN (2n4401), voltage @ emitter was about ~0.8V.

I tried using a open drain w/ the internal weak pull up resistor and the readings aren't affected much by it.

I think I found the source of the problem (though I'm not too sure why). My VDDA voltage is not within specifications outlined in the datasheet: VDDA >= VDD. As of now, I have it as VDDA = 2.048V and VDD is 3.3V.  |O Lesson learned! I'm going to change VDDA to 3.3V and see if it fixes it, but won't be getting to it soon.

Edit: I uploaded the same code onto the dev. board with the exact same chip. VDDA here is 3.3V and the readings are measuring fine.
« Last Edit: February 26, 2017, 12:21:02 am by WillHuang »
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #6 on: February 26, 2017, 01:47:12 pm »
I also almost made a design with Vdd 3.3 and Vdda 3.0 from a accurate ref.
Until I read the little * under the Vdd table saying Vdda should be the same as Vdd.
Reading a bit better shows for the 103 a 100 mv difference is allowed.

You'll need to do ref compensation in software then. Because you probably did this to have precise Vref lacking the pin.
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3469
  • Country: it
Re: STM32F303 GPIO configured as Push pull affecting ADC readings
« Reply #7 on: February 26, 2017, 08:24:11 pm »
Mmmyes.. Vdda is not Vref!

But beware that you may encounter parts that can only use Vdda for reference. As always, check the datasheet!
« Last Edit: February 26, 2017, 08:26:41 pm by JPortici »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf