I'm trying to modify stm32f103 2x16 lcd library to stm32f4. There are BRR and BSRR register on stm32f103 but there aren't similar register in GPIO_TypeDef structure on stm32f4 so i don't know how to modify these codes.



  • \$\begingroup\$ Actually there are. Check the programers manual. \$\endgroup\$ Mar 25, 2019 at 14:15
  • \$\begingroup\$ There are BSRRH (set/reset high register) and BSSRL (set/reset low register) for BSRR (set/reset register) register but which one i have to use and there are not register like BRR(reset register) in GPIO_TypeDef \$\endgroup\$
    – 7navy4
    Mar 25, 2019 at 14:39
  • 1
    \$\begingroup\$ Again, see the programmers manual. Once you understand what they do, you will understand which to use. \$\endgroup\$ Mar 25, 2019 at 14:40
  • \$\begingroup\$ @ChrisStratton unfortunately the situation is more complicated, with some headers incompatible with the description in the reference manual, low register used to set pins high... \$\endgroup\$ Mar 26, 2019 at 8:08
  • 1
    \$\begingroup\$ @ChrisStratton STM32 microcontroller documentation is split into 3 parts. The Programming Manual describes the ARM core, instruction set and core peripherals like NVIC, SCB. It does not mention GPIO at all. The Reference Manual describes the peripherals outside the ARM core, including GPIO registers. Finally, the Datasheet describes the hardware, pinouts, electrical characteristics, package dimensions. \$\endgroup\$ Mar 26, 2019 at 10:35

1 Answer 1


There are two different versions of STM32F4 headers released by ST, with some incompatibilities. The one that comes with the StdPeriph library defines 16 bit BSRRL and BSRRH, that is the one you have. The other one that comes with the STM32CubeF4 library has a single 32 bit BSRR definition, which corresponds to the reference manual.

Now check the definition in your headers

__IO uint16_t BSRRL;    /*!< GPIO port bit set/reset low register,  Address offset: 0x18      */
__IO uint16_t BSRRH;    /*!< GPIO port bit set/reset high register, Address offset: 0x1A      */

BSRRL corresponds to the low half, bits 0-15 of the BSRR register as described in the reference manual, which sets the corresponding output bit to 1 (high). BSRRH corresponds to the high half, bits 16-31 of the BSRR register, which sets the corresponding output bit to 0 (low).

You can use BSRRL instead of BSRR to turn a pin on, but keep in mind that the definition is only 16 bits, so you can't turn some bits on and some other pins off in a single operation using this definition, because the writes are truncated to 16 bits by the compiler.

BSRRL has the same function of BRR, the only difference is that the write is truncated to 16 bits by the compiler, nothing that you have to worry about unless you must count the cycles to get some timing right.


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.