Port 8 is a general I/O port also functioning as a timer W I/O pin. The register setting of timer W has priority for functions of the pins P84/FTIOD, P83/FTIOC, P82/FTIOB, and P81/FTIOA. P80/FTCI also functions as a timer W input port that is connected to the timer W regardless of the register setting of port 8.
Two registers control its functions:
• Port control register 8 (PCR8)
• Port data register 8 (PDR8)
There is no PMR8. alternative settings for the pins in this port are determined by the configuration of Timer W which has priority over the normal use of the pins.
PCR8 determines the direction of the pin. If a pin is designated as an IO pin, setting a bit in PCR8 to 1 makes the corresponding pin an output, setting it to zero makes the corresponding pin an input.
PDR8 simply holds the output data at the port 8 pins if the pin is configured as an output. Reading a pin while it is configured as an input reads the value at the pin regardless of the value in the PDR8 register.
There are no pullups available for port 8.
After a reset, this port is configured as all general purpose input pins.
Using the header files provided with the GNUH8 toolchain, port 8 and its registers are found in the IO address space and can be accessed using statements like these:
int data; IO.PCR8 = 0x0F; // set P80,P81, P82 and P83 as outputs IO.PDR8.BIT.B1 = 1; // set P81 to 1 data = IO.PDR8.BIT.B6; // read a single bit into an integer variable
You should note that the final statement may not really read the individual bit - it simply reads the whole of PDR5 into data if the optimisation level is anything other than none. Thus you should treat the answer with a little care. The compiler can be trusted to a degree since the optimiser will mask subsequent access to the variable to ensure that the required bit is used.