Chapter3-Input Output Ports Programming
Chapter3-Input Output Ports Programming
Depending on the device selected and features enabled, there are up to five ports available. Some pins of the I/O ports are multiplexed with an alternate function from the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin.
Each port has three registers for its operation. These registers are: TRIS register (data direction register) PORT register (reads the levels on the pins of the device) LAT register (output latch)
The corresponding Data Direction register is TRISx. Setting a TRISx bit (= 1) will make the corresponding PORTx pin an input (i.e., put the corresponding output driver in a high-impedance mode). Clearing a TRISx bit (= 0) will make the corresponding PORTx pin an output (i.e., put the contents of the output latch on the selected pin). The Data Latch register (LATx) is also memory mapped. Readmodify-write operations on the LATx register read and write the latched output value for PORTx.
INITIALIZING PORTA
INITIALIZING PORTC
INITIALIZING PORTD
The fourth pin of PORTE (MCLR/VPP/RE3) is an input only pin. Its operation is controlled by the MCLRE Configuration bit. When selected as a port pin (MCLRE = 0), it functions as a digital input only pin; as such, it does not have TRIS or LAT bits associated with its operation. Otherwise, it functions as the devices Master Clear input. In either configuration, RE3 also functions as the programming voltage input during programming.
INITIALIZING PORTE
End chapter 2. Please read PIC18 datasheet for detail description assembly language