2

I am using an STM32F072CB. Some of the GPIO pins are connected to a multiplexer for controlling the channel, and others are connected to some MOSFETs. The pins are configured as regular no push/no pull GPIO output pins:

enter image description here

I am having some trouble changing the output of these pins in my code. I know they are correctly connected since if I set their default output ('GPIO output level') they respond and will output as directed.

When I change their values in the code using:

HAL_GPIO_WritePin(GPIOA, ADD_2_Pin, GPIO_PIN_RESET)

or

HAL_GPIO_WritePin(GPIOA, ADD_2_Pin, GPIO_PIN_SET)

The pins simply refuse to change. Using breakpoints I am able to see the code is being reached, but it is as if the pins are constantly being reset to their original state. How can I figure out what is causing this?

JRE
  • 67,678
  • 8
  • 104
  • 179

1 Answers1

2

You are setting a pin in GPIO port A but the pin you want to set is in GPIO port B.

This could be avoided if you use both the generated pin number and pin port macros.

Justme
  • 127,425
  • 3
  • 97
  • 261
  • Thank you! Had me very confused that is for sure. For those who happen to stumble upon this question, an example os using the port macro is: ```HAL_GPIO_WritePin(ADD_0_GPIO_Port, ADD_0_Pin, GPIO_PIN_SET);``` – Tiaan Stals Jun 29 '22 at 05:40