I have got LCD interfacing code for PIC16F628A written on mikroC.
* Description:
This code demonstrates how to display test message on a LCD which
is connected to PIC16F628A through PORTB. D4-D7 pins of LCD are
connected to RB4-RB7, whereas RS and EN pins connected to RA0 and RA1
respectively.
MCU: PIC16F628A
Oscillator: XT, 4.0 MHz
*/
// LCD module connections
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// Define Messages
char message1[] = "Testing LCD";
char message2[] = "using PIC16F628A";
char message3[] = "Test Successful!";
char message4[] = "2009/09/18";
void main() {
CMCON |= 7; // Disable Comparators
Lcd_Init(); // Initialize LCD
do {
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,message1); // Write message1 in 1st row
Lcd_Out(2,1,message2); // Write message1 in 2nd row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,message3); // Write message3 in 1st row
Lcd_Out(2,1,message4);
Delay_ms(2000);
} while(1);
}
Raj
Experiments with PIC16F628A