Skip to main content
Graduate
January 12, 2024
Question

STM32F103C8 GPIO Output

  • January 12, 2024
  • 1 reply
  • 896 views

I'm trying to control LED using GPIO.

The GPIO pin settings are as follows.

PB 8~15 : input data

PB 4~7 : output LED

After analyzing the input data, I want to export the output, but when PB 4 is exported, PB 12 is turned on, and when PB 5 is exported, PB 13 is turned on.

Interference pins have no H/W connection.

How can I solve this problem??

    This topic has been closed for replies.

    1 reply

    Super User
    January 12, 2024

    A few possibilities:

    • Your code doesn't do what you think it does. There are GPIO toggling examples in the CubeMX repo. Debug your code and examine GPIO_ODR register values to ensure pin PB5 (for example) toggles when you try to toggle it. Examine GPIO_IDR to ensure pin reflects ODR value.
    • The pin you're toggling isn't connected to what you think it is. What hardware is this? Show your schematic. Recheck wiring.

    You're off by 8 in both instances. Perhaps there's a corresponding error in your code.