User manual

466
mikoPascal PRO for PIC32
MikroElektronika
Library Example
Default Pin Conguration
Use SPI_Lcd_Init for default pin settings (see the rst gure below).
Copy Code To Clipboard
program Spi_Lcd;
var text : array[16] of char;
var counter : byte;
// Port Expander module connections
var SPExpanderRST : sbit at LATD8_bit;
SPExpanderCS : sbit at LATD9_bit;
SPExpanderRST_Direction : sbit at TRISD8_bit;
SPExpanderCS_Direction : sbit at TRISD9_bit;
// End Port Expander module connections
procedure Move_Delay(); // Function used for text moving
begin
Delay_ms(500); // You can change the moving speed here
end;
begin
text := ‘mikroElektronika’;
CHECON := 0x32;
AD1PCFG := 0xFFFF; // Congure AN pins as digital
// If Port Expander Library uses SPI2 module
// Initialize SPI module used with PortExpander
SPI2_Init_Advanced(_SPI_MASTER,_SPI_8_BIT, 4, _SPI_SS_DISABLE,_SPI_DATA_SAMPLE_
MIDDLE,_SPI_CLK_IDLE_LOW,_SPI_ACTIVE_2_IDLE);
Spi_Lcd_Cong(0); // Initialize LCD over SPI interface
Spi_Lcd_Cmd(_LCD_CLEAR); // Clear display
Spi_Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
Spi_Lcd_Out(1,6, ‘mikroE’); // Print text to LCD, 1st row, 6th column
Spi_Lcd_Chr_CP(‘!’); // Append ‘!
Spi_Lcd_Out(2,1, text); // Print text to LCD, 2nd row, 1st column
// Spi_Lcd_Out(3,1,’mikroE’); // For LCD with more than two rows
// Spi_Lcd_Out(4,15,’mikroE’); // For LCD with more than two rows
Delay_ms(2000);
// Moving text
for counter := 0 to 3 do // Move text to the right 4 times
begin
Spi_Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
end;