STM32 GPIO input output problem - Page 1
Forum section: electronics / general

author: Hacked
author_rank: Contributor
timestamp: June 03, 2022, 05:02:00 pm
content: 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 03, 2022, 06:09:00 pm
content: Probably the stm32 isn't even working due wrong clock settings...Your question lacks a lot of details!

author: wek
author_rank: Frequent Contributor
timestamp: June 03, 2022, 08:32:50 pm
content: Which STM32?What is connected to given pin on the board?Read out and check/post relevant GPIO regsiters content.JW

author: thm_w
author_rank: Super Contributor
timestamp: June 03, 2022, 10:30:56 pm
content: https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.htmlIts STM32F411 or similar.Something is wrong, normally GPIO low will be 0V.Maybe you can post your code.

author: Hacked
author_rank: Contributor
timestamp: June 06, 2022, 03:05:59 pm
content: 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 06, 2022, 04:24:32 pm
content: 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: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...

author: pcprogrammer
author_rank: Super Contributor
timestamp: June 06, 2022, 05:13:11 pm
content: 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.

author: Hacked
author_rank: Contributor
timestamp: June 06, 2022, 07:39:56 pm
content: 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=wTFLoyGround connection is ok.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 07, 2022, 12:23:43 pm
content: 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.

author: Hacked
author_rank: Contributor
timestamp: June 07, 2022, 01:49:37 pm
content: Quote from: DavidAlfa on June 07, 2022, 12:23:43 pmI am total idiot.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...Sorry all for total confusion

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 07, 2022, 04:46:34 pm
content: No problem, you lit yourself in fire with this onePerhabs the tutorial used an external resistor?