Datasheet
// // If Port Expander Library uses SPI2 module
// SPI2_Init(); // Initialize SPI module used with
PortExpander
// Spi_Rd_Ptr := @SPI2_Read; // Pass pointer to SPI Read function
of used SPI module
Expander_Init(0); // Initialize Port Expander
Expander_Set_DirectionPortA(0, 0x00); // Set Expander's PORTA to
be output
Expander_Set_DirectionPortB(0,0xFF); // Set Expander's PORTB to
be input
Expander_Set_PullUpsPortB(0,0xFF); // Set pull-ups to all of
the Expander's PORTB pins
while ( TRUE ) do // Endless loop
begin
Expander_Write_PortA(0, counter); // Write i to expander's
PORTA
Inc(counter);
PORTC := Expander_Read_PortB(0); // Read expander's PORTB
and write it to LEDs
Delay_ms(100);
end;
end.
312
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6