User manual
537
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Library Example
Default Pin Conguration
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 LATF0_bit;
var SPExpanderCS : sbit at LATF1_bit;
var SPExpanderRST_Direction : sbit at TRISF0_bit;
var SPExpanderCS_Direction : sbit at TRISF1_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’;
 ADPCFG := 0xFFFF; // initialize AN pins as digital
 SPI1_Init(); // Initialize SPI
 Spi_Lcd_Cong(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
 // 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;
 while TRUE do // Endless loop
 begin
 for counter := 0 to 6 do // Move text to the left 7 times
 begin
 Spi_Lcd_Cmd(_LCD_SHIFT_LEFT);
 Move_Delay();
 end;










