User manual
417
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Expander_Init
Prototype
procedure Expander_Init(ModuleAddress : byte);
Description Initializes Port Expander using SPI communication.
Port Expander module settings:
- hardware addressing enabled
- automatic address pointer incrementing disabled (byte mode)
- BANK_0 register adressing
- slew rate enabled
Parameters - ModuleAddress: Port Expander hardware address, see schematic at the bottom of this page
Returns Nothing.
Requires Global variables:
- SPExpanderCS: Chip Select line
- SPExpanderRST: Reset line
- SPExpanderCS_Direction: Direction of the Chip Select pin
- SPExpanderRST_Direction: Direction of the Reset pin
must be dened before using this function.
SPI module needs to be initialized. See SPIx_Init and SPIx_Init_Advanced routines.
Example
// Port Expander module connections
var SPExpanderRST : sbit at LATF0_bit;
SPExpanderCS : sbit at LATF1_bit;
SPExpanderRST_Direction : sbit at TRISF0_bit;
SPExpanderCS_Direction : sbit at TRISF1_bit;
// End of Port Expander module connections
...
// If Port Expander Library uses SPI module
SPI1_Init(); // Initialize SPI module used with PortExpander
Expander_Init(0); // Initialize Port Expander
Notes None.