2023-05-12 02:58 PM
I've defined the lower 8 bits of a STM32F4 GPIO port as a negative-true open-drain output. My current code uses two 16-bit writes, first to set all 8 bits, then another to selectively clear them. It would seem that I could do this with a single 32 bit write to BSRR by setting the 8 bit complement of the value to be written, and then clearing the bits specified by the value, all with a single write. I haven't tried this yet, but will it work?
In other words, if I want to output (negative logic) 0x12, I'd write 0x001200ed to BSRR.
2023-05-12 03:25 PM
It's designed to work with a single write.
The word looks to be correct
2023-05-12 03:42 PM
Thanks; that's what I thought. it's odd that some library APIs only allow for setting or clearing bits, not both simultaneously. I note the the RM does say that in case of conflict (set/reset at the same time) that it's resolved in favor of setting.