nick703
Advanced Member level 1

PIC18f4431 and Micro C Pro code for LCD display ?
Hello Friends,
I have a pic18f4431 and micro c pro to use dispaly LCD . and I use external oscillator 20MHz. but My problem is LCD take time to operate and not working in real time means lcd display but take to much time . below is my code
and also configuration register
file.
and i would to say in proteus also print data on lcd but in real hardware take a more time to operate so what is the problem please tell me.
Hello Friends,
I have a pic18f4431 and micro c pro to use dispaly LCD . and I use external oscillator 20MHz. but My problem is LCD take time to operate and not working in real time means lcd display but take to much time . below is my code
Code:
unsigned long RPM_Value;
// Define LCD module connections.
sbit LCD_RS at RB3_bit;
sbit LCD_EN at RB2_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 TRISB3_bit;
sbit LCD_EN_Direction at TRISB2_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 connection definition
sbit IR_Tx at RD2_bit;
// Define Messages
char message1[] = "Tachometer";
char *RPM = "00000 RPM";
void Display_RPM(unsigned long num){
RPM[0] = num/10000 + 48;
RPM[1] = (num/1000)%10 + 48;
RPM[2] = (num/100)%10 + 48;
RPM[3] = (num/10)%10 + 48;
RPM[4] = num%10 + 48;
Lcd_Out(2,4,RPM);
}
void main() {
ANSEL0 = 0x00;
ANSEL1 = 0x00;
TRISD = 0x00;
PORTC = 0x00;
TRISC = 0b00001000;
T0CON = 0b01101000; // TMR0 as 16-bit counter
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,4,message1); // Write message1 in 1st row
while(1)
{
T0CON.TMR0ON = 1;
TMR0L = 0;
TMR0H = 0;
IR_Tx = 1;
Delay_ms(1000); // Wait for 1 sec
IR_Tx = 0;
T0CON.TMR0ON = 0; // Stop the timer
RPM_Value = (256*TMR0H + TMR0L)*60;
Display_RPM(RPM_Value);
RPM_Value = 0;
}; // Infinite Loop
}
and also configuration register

and i would to say in proteus also print data on lcd but in real hardware take a more time to operate so what is the problem please tell me.