Microcontroller › PIC › Stop lcd from blinking the words written to it
- This topic has 3 replies, 2 voices, and was last updated 12 years, 7 months ago by
AJISH ALFRED.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
June 14, 2013 at 11:29 am #2484
kite
ParticipantHello guys ,
Can someone tell me how to stop the words blinking in my lcd to stop blinking this is the code i use.
#include<p18f4550.h>#include<delays.h>#pragma config FOSC = INTOSC_EC#pragma WDT = OFF#define EN LATDbits.LATD7#define RS LATDbits.LATD6void lcdcmd(unsigned char Data);void lcdData(unsigned char l);void lcdinit(void);void waitlcd(int x);void prints(const rom char * message);void clearLcd(void);void main(void){OSCCON = 0b11110010;TRISD=0;TRISB=0;EN=0;lcdinit();prints(‘HI’);}void lcdcmd(unsigned char Data){RS=0; //because sending commandEN=0;PORTB
(Data >> 4) & 0x0F);EN=1;waitlcd(2);EN=0;PORTB = (Data & 0x0F);EN =1;waitlcd(2);EN=0;}void lcdData(unsigned char Data){RS=1; //because sending dataEN=0;PORTB
(Data >> 4) & 0x0F);EN=1;waitlcd(2);EN=0;PORTB = (Data & 0x0F);EN=1;waitlcd(2);EN=0;}void lcdinit(void){RS=0;EN=0;PORTB= 0x3;waitlcd(40);EN=1;EN=0;waitlcd(5);EN=1;EN=0;waitlcd(5);EN=1;EN=0;waitlcd(2);PORTB=0x2;EN=1;EN=0;lcdcmd(0x28); //set data length 4 bit 2 linewaitlcd(250);lcdcmd(0x0C); // enable display; // set display on cursor on blink onwaitlcd(250);lcdcmd(0x01); // clear lcdwaitlcd(250);lcdcmd(0x06); // cursor shift directionwaitlcd(250);lcdcmd(0x80); //set ram addresswaitlcd(250);}void waitlcd(int x){int i;for (x ;x>1;x–){for (i=0;i<=110;i++);}}void prints( const rom char * message) // Write message to LCD (C string type){lcdcmd(0xE); // enable display;while (*message){ // Look for end of stringlcdData(*message++);}}June 17, 2013 at 11:27 am #9975AJISH ALFRED
ParticipantHi Kite,
The LCD is blinking because your controller resets continuously. To prevent the controller from reset you have to apply an infinite loop like
while ( 1 )
{
;
}
I hope modifying your main function like the following will solve the issue
void main(void){OSCCON = 0b11110010;TRISD=0;TRISB=0;EN=0;lcdinit();prints(‘HI’);while ( 1 ){;}}June 23, 2013 at 9:45 am #10011kite
ParticipantThanks Ajish
June 25, 2013 at 4:23 am #10020AJISH ALFRED
ParticipantYou are welcome Kite. If you have any further queries please don’t hesitate to share with us.
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.