First page Back Continue Last page Overview Text

Notes:


The exclusive-OR gate is used to toggle (switch the state) of a bit. In the above example the state of bit 3 of PORTT (and the port image) is inverted from its previous state.

When output ports cannot be read directly, an image of the output port can be stored in memory. By modifying the port image whenever the port is modified, the contents of the port will always be known. It is important to initialize the port image and the actual port with the same initial values. If the program uses interrupts that can interrupt program flow, it may also be important to make sure that the program flow is not interrupted between the time the port image is updated and the time PORTT is updated. Because the state of output registers can be read directly on the 68HC12 (and many other but not all processors) keeping an image of a port is not necessary in this class.