Author Topic: STM32 GPIO input output problem  (Read 2340 times)

0 Members and 1 Guest are viewing this topic.

Offline HackedTopic starter

  • Contributor
  • Posts: 36
  • Country: hr
STM32 GPIO input output problem
« on: June 03, 2022, 05:02:00 pm »
Hello all,

Recently i bought few WeAct black pill boards to try STM32 microntrollers.
I am confused with how GPIO pin output works.
GPIO output pin is 2V when low in default configuration.
That changes only when I configure one GPIO input and set it to PULL-DOWN mode.
Didn't find anything in datasheet, and all tutorials I watched used default configuration with no problems, but when I used it OUTPUT pins were 2V instead of 0V when low.
It also affects SPI pins like clock SCK, it goes from 2V to 3.3V, instead 0V to 3.3V.
But when i configure on GPIO input pin in pull-down mode it all goes to normal, like I was used to with TI and Atmel ARM microcontrollers.
Strange problem, dunno if I am missing something, it probably has easy solution which I am not aware of?

 EDIT: Forgot to add that I accidentaly bricked both black pill boards because I put wrong value in clock configuration, 8MHz crystal instead of 25MHz which is soldered on board, but i resolved it with STM32 programmer by erasing all the flash, but for the life of me I can't remember if that problem was before that.
« Last Edit: June 03, 2022, 05:56:40 pm by Hacked »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6247
  • Country: es
Re: STM32 GPIO input output problem
« Reply #1 on: June 03, 2022, 06:09:00 pm »
Probably the stm32 isn't even working due wrong clock settings...
Your question lacks a lot of details!
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: sk
Re: STM32 GPIO input output problem
« Reply #2 on: June 03, 2022, 08:32:50 pm »
Which STM32?

What is connected to given pin on the board?

Read out and check/post relevant GPIO regsiters content.

JW
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7153
  • Country: ca
  • Non-expert
Re: STM32 GPIO input output problem
« Reply #3 on: June 03, 2022, 10:30:56 pm »
https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.html
Its STM32F411 or similar.

Something is wrong, normally GPIO low will be 0V.
Maybe you can post your code.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline HackedTopic starter

  • Contributor
  • Posts: 36
  • Country: hr
Re: STM32 GPIO input output problem
« Reply #4 on: June 06, 2022, 03:05:59 pm »
Thanks all on answering!
Sorry for the late reply.
In attachement's you can see pictures.
The program I created is basic, just one input (GPIO A1) and one output (GPIO B1).
Default settings, I changed just the system clock, activated external 25MHz crystal, and set the clock to 100MHz.
In first two pictures you can see voltage on input pin A1(slightly above 2V) and 1.3V on output pin B1.
When i changed GPIO A1 pin to pull-down mode then voltages are what is expected, 0V both, but every other pin is still 2V.
Nothing is connected except power as you can see in pictures so bad wiring is not the problem.
Really don't understand what is happening.
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6247
  • Country: es
Re: STM32 GPIO input output problem
« Reply #5 on: June 06, 2022, 04:24:32 pm »
That's very weird...
Although you made the bridges, don't trust them, breadboards like to fail a lot, ensure GND is properly conected, some breadboards are splitted internally.
Connect both sides of the DMM at the stm32 board pins.
If everything is ok, the only thing I can think of is the stm32 resetting randomly.

Try blinking PC13, it's the onboard led, should be a consistent on/off, you'll easily see how it toggles and there's no way you can mess the connection.

Set PC13 as output, no pull, name it LED, then:
Code: [Select]
while(1){
  HAL_GPIO_Toggle(LED_GPIO_Port, LED_Pin);
  HAL_Delay(1000);
}
Is it a 401 or a 411?
Attach your project as-is and il'll test it.

The gnd wire looks suspicious...
« Last Edit: June 06, 2022, 04:38:58 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4346
  • Country: nl
Re: STM32 GPIO input output problem
« Reply #6 on: June 06, 2022, 05:13:11 pm »
Are you sure the clocks for the GPIO's are enabled?

In the RCC_AHB1ENR register the GPIO peripherals have to be enabled to function properly. Not sure if the behavior you have can occur when they are not enabled, but worth checking.

Offline HackedTopic starter

  • Contributor
  • Posts: 36
  • Country: hr
Re: STM32 GPIO input output problem
« Reply #7 on: June 06, 2022, 07:39:56 pm »
I made two output pins, PC13 and PA10.
Bothj works, you can see oscilloscope reading in picture.
But my input pin is still 2V.
Program link is here: https://intervalri-my.sharepoint.com/:u:/g/personal/juraj_vukic_interval-ri_hr/EVLTs08epYVOtnKB1aVEx7gBZ97GASQVXZ3CZ6vbQDAKQA?e=wTFLoy
Ground connection is ok.
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6247
  • Country: es
Re: STM32 GPIO input output problem
« Reply #8 on: June 07, 2022, 12:23:43 pm »
You're mixing now! Your outputs looks fine.
You said you got 2V at the output, now at the input...Is it input or output?
In input mode, of course, floating input will have undefined voltage, you should use a pull resistor.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline HackedTopic starter

  • Contributor
  • Posts: 36
  • Country: hr
Re: STM32 GPIO input output problem
« Reply #9 on: June 07, 2022, 01:49:37 pm »
You're mixing now! Your outputs looks fine.
You said you got 2V at the output, now at the input...Is it input or output?
In input mode, of course, floating input will have undefined voltage, you should use a pull resistor.

I am total idiot. :palm:
The tutorial I followed didn't show pull resistor, of course floating input will have random voltage.
And because I had on input around 2V, and in software I made if statement which checked input pin, and if input was active the output was activated, so because input voltage was near threshold voltage, output pin was activated when input surpassed threshold voltage and that's why on output i had 1.5V... :palm:
Sorry all for total confusion  |O
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6247
  • Country: es
Re: STM32 GPIO input output problem
« Reply #10 on: June 07, 2022, 04:46:34 pm »
No problem, you lit yourself in fire with this one :-DD
Perhabs the tutorial used an external resistor?
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf