I'm a newbie to STM32 coding and struggling with the following:

I used to code a little bit with STM32F103C8T6, using cubeMx and HAL libraries. I made a code using the following code to set the pin to High:


It worked like a charm.

I just try to move my project to an STM32F446RE Nucleo. I changed a few pieces of my code but I have a compiling error I can't get rid off.

../Src/main.c(175): error:  #136: struct "<unnamed>"  has no field "BRR"

I have this error for every single line using BRR. Do you know what I should change?

Config: CubeMx, Keil, HAL Lib, STM32F446RE

Thank you

  • 3
    \$\begingroup\$ STM32F1 and STM32F4 GPIO are fairly different; you may have erroneous references/includes/code to the old target in your code \$\endgroup\$ – Chris Stratton Oct 30 '18 at 22:08
  • 4
    \$\begingroup\$ If I remember correctly the F4 doesn't come with a BRR definition. Instead you use the BSRR register and to reset a pin you have to shift it by 16. To set a pin you just use the pin directly. Make sure you are including the correct header and you are defining the right device as well. \$\endgroup\$ – Arsenal Oct 30 '18 at 22:10

BRR Register isn't defined for the GPIOs in the STM32F4 MCUs .You can use BSRR regster instead. for more information see the STM32F4-Reference manual page 286 and also STM32f4xx.h file for the registers have been defined for GPIOs.

  • \$\begingroup\$ I checked the RM but i'm not sure how to understand it. As example if i want to set PB5 named DIR; I will send GPIOB->BSRR = DIR_Pin; this is equivalent to: GPIOB->BSRR = 0x20; //(bit 5) When I went to reset, i will have to send: GPIOB->BSRR = 0x200000; // (bit 21) is it correct? \$\endgroup\$ – vib Oct 31 '18 at 10:22
  • \$\begingroup\$ yes, that's write. \$\endgroup\$ – Amin Oct 31 '18 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.