Hi Neil, hi everybody, On Thu, 27 Oct 2016 11:33:57 +0100 Neil Jones <[email protected]> wrote: > > are you suggesting the compiler generated code for accessing the > bitfeilds is less size efficient than doing it manually? I would be > suprised if that was the case ?
writing to a bitfield translates to a read followed by a write of the updated value. So if you write to multiple bitfields in a register you have multiple read-write pairs. These can't be combined when the bitfields are volatile. Similar for multiple reads of a register. When you use shift and mask you usually do a single access for all fields of a register. IMHO it is also better to use shift and mask because a write to a bitfield is actually a hidden non-atomic read-update-write, which may become dangerous when you have concurrent access. Grüße Jürgen > On 27 Oct 2016 08:05, "Hauke Petersen" <[email protected]> > wrote: > > > Hi Neil, hi Kees, > > > > though named bitfields are kind of nice when it comes to code > > readability, they behave very poorly when it comes to code size. > > This is especially true for register maps, as these are typically > > volatile. For this reason, we don't use them in RIOT and I strongly > > advice not to use those. > > > > As example I was able to save several 100 bytes of ROM when > > removing the named bitfield use from the samr21s peripheral drivers. > > > > Cheers, > > Hauke -- Jürgen Stuber <[email protected]> http://www.jstuber.net/ 1B78 A579 E159 2A85 67BB 1314 C083 224B 0F9C DA21
pgpH74g3uoWSy.pgp
Description: OpenPGP digital signature
_______________________________________________ devel mailing list [email protected] https://lists.riot-os.org/mailman/listinfo/devel
