[STM32] input !== output signal - why? - Page 1
Forum section: electronics / general

author: SunboX
author_rank: Newbie
timestamp: January 30, 2021, 01:59:32 am
content: I'm using a STM32G431KB Nucleo board (nucleo_g431kb - 170MHz) with PlatformIO & the Arduino framework.My simple code looks like this:Code:void setup(){pinMode(PA11, INPUT);pinMode(PA12, OUTPUT);}void loop(){if (digitalReadFast(PA_11) == HIGH) {digitalWriteFast(PA_12, HIGH);}else {digitalWriteFast(PA_12, LOW);}}On pin 11 I got a well defined input signal like shown in the picture below (yellow signal). The blue signal in the picture is the one from the STM32 (pin 12).Now the blue signal is not that defined like the yellow one. In theory, they both should be identical, shouldn't they? How do I get the output signal mirroring the input signal? The chip should have enough power. I tried a pull-down resistor, but it didn't change anything. I guess, I'm simply stupi.

author: techman-001
author_rank: Frequent Contributor
timestamp: January 30, 2021, 02:32:48 am
content: Quote from: SunboX on January 30, 2021, 01:59:32 amNote: I don't know anything about arduino.All STM32, work even at boot with no code at all, in that the internal default RC system clock runs. Everything else is disabled including all GPIO's.I can't see where you have enabled GPIOA ?Is your OUTPUT, open drain or push pull ?

author: ajb
author_rank: Super Contributor
timestamp: January 30, 2021, 02:55:58 am
content: Your output signal looks like it's AC coupled. It's possible there's a problem with the IO pin configuration and it's not being correctly set as an output. It's also possible that you simply have a hardware problem. It may be worth taking a look at the schematics for the nuclei board, sometimes dev boards likes that will not bring all of the IO pins out to the header but default, there may be a jumper you need to close for that particular pin. You can rule a few things out by simply trying a different pin.

author: georges80
author_rank: Frequent Contributor
timestamp: January 30, 2021, 03:08:39 am
content: Haven't played with the stm32g family, but if it is like the stm32l and stm32f families, then you can configure the 'speed' of each output pin, which affects the drive strength and thus slew speed.cheers,george.

author: ozcar
author_rank: Frequent Contributor
timestamp: January 30, 2021, 04:43:47 am
content: As ajb said, the output looks like it is AC coupled. Are you sure your probe is OK? Maybe try swapping the two probes just to be sure.Did you have the pinModes in setup() interchanged at first? The code as quoted by techman-001 has them the wrong way around.

author: techman-001
author_rank: Frequent Contributor
timestamp: January 30, 2021, 05:23:34 am
content: Quote from: ozcar on January 30, 2021, 04:43:47 amI quoted the OP's post exactly.I agree that it's an AC signal however the blue scope channel is set to 500mv/div and has a dc voltage of about one volt on it. I suspect that because the pins concerned are right next to each other and PA-12 (output) is simply picking up the PA-11 (input) signal via the inherent capacitance between the PCB pins/circuit tracks.Perhaps the MODE of PA12 (and PA11 are still un-configured) and set as inputs ?

author: newbrain
author_rank: Super Contributor
timestamp: January 30, 2021, 09:14:21 am
content: Many crazy and less crazy hypotheses thrown around, but it would seem everyone, including the OP, missed the obvious!Does anyone see something strange in the code below:Code:pinMode(PA12, INPUT);[...]digitalWriteFast(PA_12, HIGH);andCode:pinMode(PA11, OUTPUT);[...]if (digitalReadFast(PA_11) == HIGH) {

author: ozcar
author_rank: Frequent Contributor
timestamp: January 30, 2021, 09:54:59 am
content: Quote from: newbrain on January 30, 2021, 09:14:21 amI did not miss that, nor it seems did OP, as they changed their posted code after techman-001 quoted it (which is why I asked about it).