# How to modify BRR and BRSS registers to stm32f4 from stm32f103

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.

LCD16X2_GPIO_D5->BSRR = LCD16X2_PIN_D5;

LCD16X2_GPIO_D4->BRR = LCD16X2_PIN_D4;

• Actually there are. Check the programers manual. Mar 25, 2019 at 14:15
• 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 Mar 25, 2019 at 14:39
• Again, see the programmers manual. Once you understand what they do, you will understand which to use. Mar 25, 2019 at 14:40
• @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... Mar 26, 2019 at 8:08
• @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. Mar 26, 2019 at 10:35

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.

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

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.