Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 connection definition // Define Messages char message1[] = "Welcome to"; char message2[] = "My world"; void main() { //ANSEL = 0b00000000; //All I/O pins are configured as digital CMCON = 0x07 ; // Disbale comparators TRISB = 0b00000000; // PORTC All Outputs TRISA = 0b00000000; // PORTA All Outputs, Except RA3 Lcd_Init(); // Initialize LCD do { Lcd_Cmd(_LCD_CLEAR); // CLEAR display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,4,message1); // Write message1 in 1st row Lcd_Out(2,1,message2); // Write message2 in 2nd row Delay_ms(1000); // Wait for 1 sec Lcd_Cmd(_LCD_CLEAR); // Clear display Delay_ms(1000); // Wait for 1 sec } while(1); // Infinite Loop }
That is one of many possible reasons. Lets wait for Alberto Dan to report back before jumping to conclusions.I know why it is not working. He either doesn't have a Crystal Oscillator or if he has one say 4 MHz then in project settings it is set to HS instead of XT.
In proteus simulation it's work but in real implementation it's not work.
What I was checking was the delay between the PIC powering up and the LCD powering up. When the supply is turned on, the LCD internal processor takes about 0.1 second to initialize before it will accept any commands. In your schematic, the -MCLR pin was conected directly to VDD so the PIC would inmnitialize immediately. There was a danger that the PIC sent commands to the LCD before it was ready to accept them. The very first commands to the LCD are to configure it and if those are missed, the LCD will never display anything. By resetting the PIC (pulling -MCL to VSS) after the LCD has powered up you would ensure the LCD was ready to operate.What should be happened?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?