1

I'm using a STM32G431KB Nucleo board (nucleo_g431kb - 170MHz) with PlatformIO & the Arduino framework.

My simple code looks like this:

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.

enter image description here

André Fiedler
  • 1,093
  • 4
  • 16
  • 25
  • Does that yellow signal peak at 1V? Assuming you are feeding the ESP32 with 3.3V, 1V is inbetween 0 and 1 (undefined). What happens when you use a 2.5V input signal? – ocrdu Jan 30 '21 at 02:00
  • It should be 3.3V, it's coming from an Wemos D1 Mini. Just the "resolution" of the oszi is set to 1V. – André Fiedler Jan 30 '21 at 02:18
  • I measured it, it's approximately 2.86 V https://i.imgur.com/YSUwPsA.jpg – André Fiedler Jan 30 '21 at 02:27
  • Should be enough. You read from a pin defined as an output, and write to a pin defined as an input, if I am not mistaken, that could well be it. – ocrdu Jan 30 '21 at 02:32
  • You are right! *facepalm* Changed it, but it didn't change much related to the curve. :/ – André Fiedler Jan 30 '21 at 02:33
  • OK, could you try with two other pins? You have put an external voltage on a pin defined as output and set to LOW (by default); you may have fried that pin. – ocrdu Jan 30 '21 at 02:45
  • Does it work if you convert from the pin name pinMode(pinNametoDigitalPin(PA_12),OUTPUT) ? etc. – user3486184 Jan 30 '21 at 03:07
  • Yes, it could also be you have connected to the wrong pins; double check to see if things are indeed connected to PA_11 and PA_12 by using pinNametoDigitalPin() as suggested by user3486184, and if the PA11 and PA12 (without underscores) you set are somehow identical to the PA_11 and PA_12 you use for reading and writing. – ocrdu Jan 30 '21 at 10:22
  • Did you find a solution? On my stm32L4 on pin PA2 set as an input with no internal pullup and an external pullup to 3.3V via a 47k resistor. I am seeing a random square wave going from 0 to 3.3V at about 31.6khz on a few boards with the same code running. Sometimes a power cycle fixes the problem sometimes it doesn't. The 3.3V external pull up always shows a solid 3.3V. – BeachMiles Jul 05 '22 at 23:36

1 Answers1

0

Try internal pullup resistor such as

pinMode(PA12, OUTPUT_PULLUP);

Also try changing the output pin as a test because it seems like something else( some other process) is trying to also trying to pull same output pin.

A 786
  • 488
  • 1
  • 6
  • 16