On Fri, 28 Oct 2016 10:03:17 +0200 Juergen Stuber <[email protected]> wrote: > > When you use shift and mask you usually do a single access for > all fields of a register.
Note that you shouldn't do it in two assignments
(I'm seeing this in cpu/stm32l1/periph/gpio.c):
port &= ~mask;
port |= (new_value << shift);
This will result in bigger code and the first assignment will write a
spurious value to the register, which might cause problems.
port = (port & ~mask) | (new_value << shift);
is better. Or
port = (port & ~mask)
| (new_value1 << shift1)
...
| (new_valueN << shiftN);
for multiple fields.
Grüße
Jürgen
--
Jürgen Stuber <[email protected]>
http://www.jstuber.net/
1B78 A579 E159 2A85 67BB 1314 C083 224B 0F9C DA21
pgpJB3i7Qqqg0.pgp
Description: OpenPGP digital signature
_______________________________________________ devel mailing list [email protected] https://lists.riot-os.org/mailman/listinfo/devel
