liveBook · Manning

BSRR

As explained in Embedded Software with Rust

BSRR is an STM32 GPIO bit set/reset register that atomically sets or clears individual output bits without reading the current port state.

The STM32 GPIO bit set/reset register (BSRR) changes selected output bits with one write, without first reading the port. This avoids the read-modify-write races that can occur when updating the Output Data Register (ODR). section 5.3.1 section 5.2.2

Set a pin through a raw register write

Writing 1 << 0 to BSRR sets PA0. The raw-pointer approach requires a valid device address and correct peripheral setup; the example uses a volatile write. section 5.3.1

gpioc.bsrr().write(|w| w.br13().set_bit());

A generated Peripheral Access Crate (PAC) can express a BSRR write through named register fields. section 5.3.3

BSRR writes can set or reset multiple pins at once. Use the register’s write operation for these updates; unlike modify, it does not read the current register value first. section 5.3.3

How Embedded Software with Rust covers it

How deep it goes
Explains atomic bit updates and shows raw and PAC writes, while noting manual raw access requires correct addresses and setup.
Examples
Shows setting PA0 through a raw pointer and setting or resetting pins through PAC register fields.
What it assumes
Requires the GPIO clock and pin configuration for raw access, and identifies these setup conditions without developing them fully.
What you can do after
Apply BSRR writes through a PAC to set or reset one or more GPIO pins without reading the register first.
How it connects
Connects BSRR with GPIO, ODR, memory-mapped I/O, PACs, and read-modify-write updates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.