Hi,
I am facing some problem in LCD interfacing. Im displaying some characters like "ABCDEX" 4bit mode on TIVAC123GH6PM. It works fine for some time after that start showing some garbage characters.what can be problem. Also I tested with single character like 'A' it display fine but when I replaced it with 'W' it shows some garbage character. some more characters like 'G' ,'K' also shows garbage. What can be problem.It LCD got corrupted?Also LCD Back-light flickering.
Here is code:
//PB0-3 signal output
//PB4-7 command in/out, data in/out
void PortB_Init(void)
{
SYSCTL_RCGCGPIO_R = 0X02;
while((SYSCTL_PRGPIO_R & 0x02)==0);
GPIO_PORTB_LOCK_R = 0X4C4F434B;
GPIO_PORTB_CR_R = 0xFF;
GPIO_PORTB_AMSEL_R = 0x00;
GPIO_PORTB_AFSEL_R = 0x00;
GPIO_PORTB_PCTL_R = 0X00000000;
GPIO_PORTB_DIR_R = 0xFF;
GPIO_PORTB_DEN_R = 0xFF;
}
void LCD_WriteNibble(uint8_t data,unsigned char control)
{
while(1)
{
//if(LCD_Busy() == 0)
break;
}
GPIO_PORTB_DIR_R = 0xFF; //make portB dir output
data &= 0xF0; //get data bits
control &= 0x0F; //get control bits
GPIO_PORTB_DATA_R = data|control; //data part hinibble
GPIO_PORTB_DATA_R = data|control|EN; //EN=1,RS=0,RW=0
msDelay(2);
GPIO_PORTB_DATA_R &= 0xF0; //EN=0
GPIO_PORTB_DATA_R = 0;
}
void LCD_Write(uint32_t data)
{
LCD_WriteNibble(data & 0xF0,RS); //hiniible data
LCD_WriteNibble(data << 4,RS); //lownibble data
}
void LCD_Command(uint8_t cmd)
{
LCD_WriteNibble(cmd & 0xF0,0); //hiniible command
LCD_WriteNibble(cmd << 4,0); //low nibble of command
if(cmd < 4)
msDelay(2);// 2 milisec delay
else
usDelay(40);
}
void LCD_Init(void)
{
PortB_Init(); //initialize port
msDelay(20); //LCD initialization
LCD_WriteNibble(0x30,0);
msDelay(20);
LCD_WriteNibble(0x30,0);
msDelay(20);
LCD_WriteNibble(0x30,0);
msDelay(20);
LCD_WriteNibble(0x20,0); // use 4-bit data mode
usDelay(40);
LCD_Command(0x28); //set 4-bit data,2-line,5x7 font
LCD_Command(0x05); //move cursor left after write a character
LCD_Command(0x01); //clear screen .move cursor to home
LCD_Command(0x0F); //turn on Display,cursor blinking
}
int main(void)
{
LCD_Init();
while(1)
{
LCD_Command(0x01); //clear screen .move cursor to home
LCD_Command(0x8F); //lcd cursor location
//LCD_Command(0x0C); //Display on cursor off
msDelay(500);//500milisec delay
LCD_Write('A');msDelay(100);
LCD_Write('B');msDelay(100);
LCD_Write('C');msDelay(100);
LCD_Write('D');msDelay(100);
LCD_Write('E');msDelay(100);
LCD_Write('F');msDelay(100);
LCD_Write('X');msDelay(100);
LCD_Write('Y');msDelay(100);
LCD_Write('Z');msDelay(100);
msDelay(500);
}
}
Please help in this regard.
Thanks,
Dheeraj