Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Expander_Set_PullUpsPortAB
Library Example
The example demonstrates how to communicate with Port Expander MCP23S17.
Note that Port Expander pins A2 A1 A0 are connected to GND so Port Expander Hardware
Address is 0.
program PortExpander;
// Port Expander module connections
var SPExpanderRST : sbit at PORTB.B0;
SPExpanderCS  : 
sbit at PORTB.B1;
SPExpanderRST_Direction : 
sbit at DDRB.B0;
SPExpanderCS_Direction  : 
sbit at DDRB.B1;
// End Port Expander module connections
var counter : byte;// = 0;
begin
counter := 0;
DDRC := 0xFF;                          // Set PORTC as output
// If Port Expander Library uses SPI1 module
SPI1_Init();                     // Initialize SPI module used with PortExpander 
Spi_Rd_Ptr := @SPI1_Read// Pass pointer to SPI Read function of used SPI module
311
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure Expander_Set_PullUpsPortAB(ModuleAddress: byte;
PullUps: word);
Returns
Nothing.
Description
The function sets Port Expander's PortA and PortB pull up/down resistors.
Parameters : 
ModuleAddress
: Port Expander hardware address, see schematic at the bot
tom of this page 
PullUps
: data for choosing pull up/down resistors configuration. PortA pull 
up/down resistors configuration is passed in PullUps's higher byte. PortB pull 
up/down resistors configuration is passed in PullUps's lower byte. Each bit cor
responds to the appropriate pin of the PortA/PortB register. Set bit enables 
pull-up for corresponding pin. 
Requires
Port Expander must be initialized. See Expander_Init.
Example
// Set Port Expander's PORTA and PORTB pull-up resistors
Expander_Set_PullUpsPortAB(0, 0xFFFF);