Author Topic: [STM32] input !== output signal - why?  (Read 2962 times)

0 Members and 1 Guest are viewing this topic.

Offline SunboXTopic starter

  • Newbie
  • Posts: 5
  • Country: de
[STM32] input !== output signal - why?
« on: January 30, 2021, 01:59:32 am »
I'm using a STM32G431KB Nucleo board (nucleo_g431kb - 170MHz) with PlatformIO & the Arduino framework.

My simple code looks like this:
Code: [Select]
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.


« Last Edit: January 30, 2021, 02:35:09 am by SunboX »
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: [STM32] input !== output signal - why?
« Reply #1 on: January 30, 2021, 02:32:48 am »
I'm using a STM32G431KB Nucleo board (nucleo_g431kb - 170MHz) with PlatformIO & the Arduino framework.

My simple code looks like this:
Code: [Select]
void setup()
{
  pinMode(PA12, INPUT);
  pinMode(PA11, 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.



Note: 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 ?
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2867
  • Country: us
Re: [STM32] input !== output signal - why?
« Reply #2 on: January 30, 2021, 02:55:58 am »
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.
« Last Edit: January 30, 2021, 03:00:26 am by ajb »
 

Offline georges80

  • Frequent Contributor
  • **
  • Posts: 932
  • Country: us
Re: [STM32] input !== output signal - why?
« Reply #3 on: January 30, 2021, 03:08:39 am »
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.
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 405
  • Country: au
Re: [STM32] input !== output signal - why?
« Reply #4 on: January 30, 2021, 04:43:47 am »
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.
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: [STM32] input !== output signal - why?
« Reply #5 on: January 30, 2021, 05:23:34 am »
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.

I 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 ?
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1918
  • Country: se
Re: [STM32] input !== output signal - why?
« Reply #6 on: January 30, 2021, 09:14:21 am »
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: [Select]
  pinMode(PA12, INPUT);
[...]
    digitalWriteFast(PA_12, HIGH);

and
Code: [Select]
  pinMode(PA11, OUTPUT);
[...]
  if (digitalReadFast(PA_11) == HIGH) {
« Last Edit: January 30, 2021, 09:42:59 am by newbrain »
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 405
  • Country: au
Re: [STM32] input !== output signal - why?
« Reply #7 on: January 30, 2021, 09:54:59 am »
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: [Select]
  pinMode(PA12, INPUT);
[...]
    digitalWriteFast(PA_12, HIGH);

and
Code: [Select]
  pinMode(PA11, OUTPUT);
[...]
  if (digitalReadFast(PA_11) == HIGH) {

I 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).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->