Working with Peripheral Module Registers

This section highlights the issues and recommends programming style for using bit fields to access memory mapped I/O. Memory mapped I/O is a way of accessing devices that are not on the system. A part of the normal address space is mapped to I/O ports. A read/write to that memory location triggers an access to the I/O device, though to the program it seems like a normal memory access. Even if one byte is written to in the space allocated to a peripheral register, the whole register is written to. So the other byte of the peripheral register will not retain its data. This may happen because the compiler generates optimal bit-field instructions with a read(byte)-mask-writeback(byte) code sequence.

This topic contains the following sub-topics: