User manual

mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
377
Library Example
The following code demonstrates usage of the Lcd Library routines:
Copy Code To Clipboard
program Lcd_Test;
// LCD module connections
var LCD_RS : sbit at LATD0_bit;
var LCD_EN : sbit at LATD1_bit;
var LCD_D4 : sbit at LATB0_bit;
var LCD_D5 : sbit at LATB1_bit;
var LCD_D6 : sbit at LATB2_bit;
var LCD_D7 : sbit at LATB3_bit;
var LCD_RS_Direction : sbit at TRISD0_bit;
var LCD_EN_Direction : sbit at TRISD1_bit;
var LCD_D4_Direction : sbit at TRISB0_bit;
var LCD_D5_Direction : sbit at TRISB1_bit;
var LCD_D6_Direction : sbit at TRISB2_bit;
var LCD_D7_Direction : sbit at TRISB3_bit;
// End LCD module connections
var txt1 : array[16] of char;
txt2 : array[11] of char;
txt3 : array[8] of char;
txt4 : array[7] of char;
i : byte; // Loop variable
procedure Move_Delay(); // Function used for text moving
begin
Delay_ms(500); // You can change the moving speed here
end;
begin
ADPCFG := 0xFFFF; // Congure AN pins as digital I/O
txt1 := ‘mikroElektronika’;
txt2 := ‘EasydsPIC4A’;
txt3 := ‘Lcd4bit’;
txt4 := ‘example’;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
LCD_Out(1,6,txt3); // Write text in rst row
LCD_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
LCD_Out(1,1,txt1); // Write text in rst row
Lcd_Out(2,3,txt2); // Write text in second row
Delay_ms(500);