Download BigPIC6 Development System User Manual
Transcript
BigPIC6 Development System 20.0. Port Expander (Additional Input/Output Ports) The SPI communication lines and MCP23S17 circuit provide the BigPIC6 development system with a means of increasing the number of available I/O ports by two. If the port expander communicates to the microcontroller over the DIP switch SW11 then the microcontroller pins RE0, RE1, RC5, RC4 and RC3, used for the operation of port expander, cannot be used as I/O pins. The microcontroller communicates to the port expander (MCP23S17 circuit) using serial communication (SPI). The advantage of such communication is that only five lines are used for transmitting and receiving data simultaneously: PORT0 PORT1 Jumper for selecting pull-up/pull-down resistor Figure 20-1: Port expander Figure 20-2: Position of DIP switch SW11 when port expander is enabled MOSI MISO SCK CS RST LD85 LD84 LD83 LD82 LD81 LD80 LD79 LD78 LD77 LD76 LD75 LD74 LD73 LD72 LD71 P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0 P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0 VCC P1.0 P1.2 P1.4 P1.6 RH1 RH0 RE2 RE3 RE4 RE5 RE6 RE7 RD0 VCC GND RD1 RD2 RD3 RD4 RD5 RD6 RD7 RJ0 RJ1 J15 VCC 8x2K2 LD86 VCC RH2 RH3 RE1 RE0 RG0 RG1 RG2 RG3 MCLR RG4 GND VCC RF7 RF6 RF5 RF4 RF3 RF2 RH7 RH6 RN22 RN21 P1_LED P0_LED - Master Output, Slave Input (microcontroller output, MCP23S17 input) - Master Input, Slave Output (microcontroller input, MCP23S17 output) - Serial Clock (microcontroller clock signal) - Chip Select (enables data transfer) - Reset Data transfer is performed in both directions simultaneously by means of MOSI and MISO lines. The MOSI line is used for transferring data from the microcontroller to the port expander, whereas the MISO line transfers data from the port expander to the microcontroller. The microcontroller initializes data transfer when the CS pin is driven low (0V). It causes the microcontroller to send clock signal (SCK) and therefore starts data exchange. The principle of operation of the port expander’s ports 0 and 1 is almost identical to the operation of other ports on the development system. The only difference here is that port signals are received in parallel format. The MCP23S17 converts then such signals into serial format and sends them to the microcontroller. The result is a reduced number of lines used for sending signals from ports 0 and 1 to the microcontroller. 8x2K2 PIC18Fxx RJ2 RJ3 RB0 RB1 RB2 RB3 RB4 RB5 RB6 GND OSC2 OSC1 VCC RB7 RC5 RC4 RC3 RC2 RJ7 RJ6 RH5 RH4 RF1 RF0 AVCC AGND RA3 RA2 RA1 RA0 GND VCC RA5 RA4 RC1 RC0 RC6 RC7 RJ4 RJ5 page 26 PORT1 P1.1 P1.3 P1.5 P1.7 U7 P1.0 CN11 P1.1 VCC P1.2 RN20 P1.3 P1.4 P1.5 P1.6 P1.7 8x10K VCC VCC PE-CS# SW11 RE0 RE1 RC5 RC4 RC3 PE-CS# PE-RST SPI-MOSI SPI-MISO SPI-SCK SPI-SCK SPI-MOSI R17 100K P0_LED P1_LED Figure 20-3: Port expander schematic MikroElektronika SPI-MISO GPB0 GPB1 GPB2 GPB3 GPB4 GPB5 GPB6 GPB7 VCC GND CS SCK SI SO GPA7 GPA6 GPA5 GPA4 GPA3 GPA2 GPA1 GPA0 INTA INTB RESET GND GND GND MCP23S17 VCC VCC P0.0 P0.2 P0.4 P0.6 PORT0 VCC P0.1 P0.3 P0.5 P0.7 J14 P0.7 P0.6 P0.5 CN10 VCC RN19 P0.4 P0.3 P0.2 P0.1 P0.0 8x10K PE-RST DIP switch SW11 enables port expander