Выбрать главу

Figure 2.23: PIC18F452 PORTB RB4–RB7 pins

Port pins RB4–RB7 can be used as interrupt-on-change inputs, whereby a change on any of pins 4 through 7 causes an interrupt flag to be set. The interrupt enable and flag bits RBIE and RBIF are in register INTCON.

PORTC, PORTD, PORTE, and Beyond

In addition to PORTA and PORTB, the PIC18F452 has 8-bit bidirectional ports PORTC and PORTD, and 3-bit PORTE. Each port has its own data register (e.g., PORTC), data direction register (e.g., TRISC), and data latch register (e.g., LATC). The general operation of these ports is similar to that of PORTA.2.1.

In the PIC18F452 microcontroller PORTC is multiplexed with several peripheral functions as shown in Table 2.8. On a power-on reset, PORTC pins are configured as digital inputs.

Table 2.8: PIC18F452 PORTC pin functions

Pin Description
RC0/T1OSO/T1CKI  
RC0 Digital I/O
T1OSO Timer 1 oscillator output
T1CKI Timer 1/Timer 3 external clock input
RC1/T1OSI/CCP2  
RC1 Digital I/O
T1OSI Timer 1 oscillator input
CCP2 Capture 2 input, Compare 2 and PWM2 output
RC2/CCP1  
RC2 Digital I/O
CCP1 Capture 1 input, Compare 1 and PWM1 output
RC3/SCK/SCL  
RC3 Digital I/O
SCK Synchronous serial clock input/output for SPI
SCL Synchronous serial clock input/output for I²C
RC4/SDI/SDA  
RC4 Digital I/O
SDI SPI data in
SDA I²C data I/O
RC5/SDO  
RC5 Digital I/O
SDO SPI data output
RC6/TX/CK  
RC6 Digital I/O
TX USART transmit pin
CK USART synchronous clock pin
RC7/RX/DT  
RC7 Digital I/O
RX USART receive pin
DT USART synchronous data pin

In the PIC18F452 microcontroller, PORTD has Schmitt trigger input buffers. On a power-on reset, PORTD is configured as digital input. PORTD can be configured as an 8-bit parallel slave port (i.e., a microprocessor port) by setting bit 4 of the TRISE register. Table 2.9 shows functions of PORTD pins.

Table 2.9: PIC18F452 PORTD pin functions

Pin Description
RD0/PSP0  
RD0 Digital I/O
PSP0 Parallel slave port bit 0
RD1/PSP1  
RD1 Digital I/O
PSP1 Parallel slave port bit 1
RD2/PSP2  
RD2 Digital I/O
PSP2 Parallel slave port bit 2
RD3/PSP3  
RD3 Digital I/O
PSP3 Parallel slave port bit 3
RD4/PSP4  
RD4 Digital I/O
PSP4 Parallel slave port bit 4
RD5/PSP5  
RD5 Digital I/O
PSP5 Parallel slave port bit 5
RD6/PSP6  
RD6 Digital I/O
PSP6 Parallel slave port bit 6
RD7/PSP7  
RD7 Digital I/O
PSP7 Parallel slave port bit 7