User manual
mikroPascal PRO for PIC32
MikroElektronika
347
Port Expander Library
mikroPascal PRO for PIC32 provides a library for communication with the Microchip’s Port Expander MCP23S17 via
SPI interface. Connections of the PIC32 MCU and MCP23S17 is given on the schematic at the bottom of this page.
Important:
- The library uses the SPI module for communication. User must initialize the appropriate SPI module before using
the Port Expander Library.
- For MCUs with multiple SPI modules it is possible to initialize all of them and then switch by using the SPI_Set_
Active() function. See the SPI Library functions.
- Library does not use Port Expander interrupts.
Library Dependency Tree
The following variables must be dened
in all projects using Port Expander
Library:
Description: Example:
var SPExpanderRST : sbit; sfr;
external;
Reset line.
var SPExpanderRST : sbit at LATF0_
bit;
var SPExpanderCS : sbit; sfr;
external;
Chip Select line.
var SPExpanderCS : sbit at LATF1_
bit;
var SPExpanderRST_Direction :
sbit; sfr; external;
Direction of the Reset pin.
var SPExpanderRST_Direction : sbit
at TRISF0_bit;
var SPExpanderCS_Direction :
sbit; sfr; external;
Direction of the Chip Select pin.
var SPExpanderCS_Direction : sbit at
TRISF1_bit;
External dependencies of Port Expander Library
Library Routines
- Expander_Init
- Expander_Init_Advanced
- Expander_Read_Byte
- Expander_Write_Byte
- Expander_Read_PortA
- Expander_Read_PortB
- Expander_Read_PortAB
- Expander_Write_PortA
- Expander_Write_PortB
- Expander_Write_PortAB
- Expander_Set_DirectionPortA
- Expander_Set_DirectionPortB
- Expander_Set_DirectionPortAB
- Expander_Set_PullUpsPortA
- Expander_Set_PullUpsPortB
- Expander_Set_PullUpsPortAB