Skip to main content
deep_rune
Associate III
Aug 18, 2020 5:33 PM UTC
Solved

Fastest way to set output pin?

I have an interrupt which I'm trying to streamline (for an STM32F031K6). I am using some commands like

GPIOA->BSRR |= (1<<4);

and i was surprised to see how much there is in this command in the disassembly. Is there any faster way of implementing this?

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Aug 18, 2020 6:59 PM UTC

GPIOA->BSRR = (1<<4); // Singular write, as designed, not RMW

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

4 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Aug 18, 2020 6:59 PM UTC

GPIOA->BSRR = (1<<4); // Singular write, as designed, not RMW

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TDK
Aug 18, 2020 8:44 PM UTC

There is never a need to read the BSRR register. It always reads as zero.

The current output state is given in the ODR register.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Uwe Bonnes
Chief
Aug 19, 2020 9:07 AM UTC

If you want to go fats, make sure GPIOA->BSRR is read from RAM, not Flash. Wait state to read that data may apply.

deep_rune
deep_runeAuthor
Associate III
Aug 19, 2020 9:31 AM UTC

interesting, how do i do that?