PIC 16F887 > LCD 2 x 16 > 4 datas bits > Can not print on LCD a char or a string

Status
Not open for further replies.

kawauso

New Member
Bonsoir,

Here in the attached file my code. I do not understand why Lcd_Out routine of Mikroe runs only. When I tried to run my own routines (2 versions), lines 161 to 166 ... here after, I can't display the string "Bonjour !". In the code I insert "//" in front of these 6 routines, in order to test each, one after one.

LCD_Write_String("Bonjour !");
LCD_Write_String_v2("Bonjour !");
LCD_String_Position(1, 1, "Bonjour !");
LCD_String_Position_v2(1, 1, "Bonjour !");
LCD_String_Position(1, 1, *pointeur_de_char);
LCD_String_Position_v2(1, 1, *pointeur_de_char);

Do anyone have an idea why they do not run ?

Merci beaucoup !
 

Attachments

  • PIC 16F887 - LCD - MikroC - My own outines failed.txt
    6.7 KB · Views: 193
You're writing to the whole of port B and therefore changing RS whenever you write.

Look at your write data routine,
Code:
void LCD_Write_Data(char mot)                                 // OK.
{
LCD_RS = 1;                                                  // Select Data Register.
Delay_us(5);
PORTB = mot >> 4;                                            // Send upper nibble.
LCD_E_Pulse();
PORTB = mot & 0x0F;                                          // Send lower nibble.
LCD_E_Pulse();
}
You set RS high then clear it when you write the upper nibble.

Mike.
Edit, it would be better to have a write nibble routine which AND/ORs the data bits in.
Edit2, combined with the pulse enable,
Code:
void writeNibble(unsigned char dat){
   PORTB=PORTB&0xf0|(dat&0x0f);
   LCD_EN = 1;
   Delay_us(1);
   LCD_EN = 0;
   Delay_us(1);
}
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…