Apart from the register structure what is the difference between GPIOx_ODR and GPIOx_BSRR?
Is GPIOx_BSRR an abstraction layer for GPIOx_ODR? I know that a change in GPIOx_BSRR "will" change the GPIOx_ODR but how and what are the diferences?

More info:

  • registers description page-162 of STM32F0advanced ARM.pdf
  • MCU STM32F051R8
  • compiler arm-none-eabi-gcc -v gcc version 4.8.3
  • 2
    \$\begingroup\$ The main point is to avoid read-modify-write operations. \$\endgroup\$ – Chris Stratton Feb 8 '14 at 14:09

The BSRR has bitfields that allow you to set and clear bits in a port atomically--without a read-modify-write operation. Instead of reading the ODR value, ORing it with the bits to set, and writing it back, you simply perform a single 32-bit write to the BSRR to set or only the relevant bits.

This often means you don't have to disable interrupts or use other concurrency protections when using the BSRR, and results in smaller and faster code for bit twiddling operations.


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.