0
\$\begingroup\$

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:

   GPIOB->BRR = STEP_Pin;

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

\$\endgroup\$
  • 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
4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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