STM32F303 GPIO configured as Push pull affecting ADC readings - Page 1
Forum section: electronics / general

author: WillHuang
author_rank: Contributor
timestamp: February 25, 2017, 03:20:10 am
content: 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.

author: Jeroen3
author_rank: Super Contributor
timestamp: February 25, 2017, 09:04:06 am
content: 1.8V is a lot. Either your circuit isn't working as expected, or the board is assembled poorly.

author: AndyC_772
author_rank: Super Contributor
timestamp: February 25, 2017, 09:27:19 am
content: What actually happens to the voltage on PA3? Does it change at all when you change the level on PA0?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 25, 2017, 11:38:39 am
content: 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

author: Throy
author_rank: Regular Contributor
timestamp: February 25, 2017, 12:44:26 pm
content: 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?

author: WillHuang
author_rank: Contributor
timestamp: February 26, 2017, 12:14:41 am
content: Quote from: Jeroen3 on February 25, 2017, 09:04:06 amSorry, 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.Quote from: AndyC_772 on February 25, 2017, 09:27:19 amWhen 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.Quote from: T3sl4co1l on February 25, 2017, 11:38:39 amADC is being driven by a buffered op amp, followed by a RC network. I don't see any noise on the scope either.Quote from: Throy on February 25, 2017, 12:44:26 pmI 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.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.

author: Jeroen3
author_rank: Super Contributor
timestamp: February 26, 2017, 01:47:12 pm
content: 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.

author: JPortici
author_rank: Super Contributor
timestamp: February 26, 2017, 08:24:11 pm
content: Mmmyes.. Vdda is not Vref!But beware that you may encounter parts that can only use Vdda for reference. As always, check the datasheet!