This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

problem in interfacing LCD with tm4c123gh6pm

Other Parts Discussed in Thread: TM4C123GH6PM

Hi

i am trying to interface LCD with tm4c123gh6pm controller but its not working,i m using Keil 4.74 version software for programming..below i paste my code,

#include <tm4c123gh6pm.h>

unsigned int i,j;

void delay(unsigned int r)
{
for(i=0;i<r;i++)
for(j=0;j<r;j++);
}

int cmd(unsigned int a)
{
GPIOE->DATA=0<<1;
GPIOE->DATA=0<<2;
GPIOB->DATA=a;
GPIOE->DATA=1<<3;
delay(150);
GPIOE->DATA=0<<3;
}

int data(unsigned int b)
{
GPIOE->DATA=1<<1;
GPIOE->DATA=0<<2;
GPIOB->DATA=b;//delay(100);
GPIOE->DATA=1<<3;
delay(150);
GPIOE->DATA=0<<3;
}
int lcd_init()
{
cmd(0x38);
cmd(0x0E);
cmd(0x01);
cmd(0x80);
}

int main()
{
SYSCTL->RCC=(1<<6|1<<8|1<<10|1<<22|1<<25);//sytem clk set,pll enabled,xtal crystal 16MHZ,sysdiv-5 40MHZ
//SystemInit();
SYSCTL->RCGCGPIO=(1<<1|1<<4);//configure port E and port B
GPIOE->DIR=0XFF;//set port E as o/p
GPIOE->AFSEL=0X00;//alternate fun as GPIO
GPIOE->DEN=0XFF;//enable digital pins
GPIOB->DIR=0XFF;//set port B as o/p
GPIOB->AFSEL=0X00;//alternate fun as GPIO
GPIOB->DEN=0XFF;//enable digital pins
lcd_init();


while(1)

{

data('A');

}

}

above is my code.. is there any mistake in my code.my problem is cursor is displaying properly but my data is not..

  • Always delightful to read user's Direct Register Macro code.    (Or not!)

    Do realize that few here have committed each/every Register Bit to memory - thus we're forced to: search, find, and painstakingly review each register's description - to fully confirm your code.    Might that be asking a, "bit much" of your helpers?

    Vendor here provides an extensive and long proven API - rich in detailed code examples.    That API "escapes" the need for the Register, "Search & Find" - surely speeding, easing & enhancing your code efforts.   (and the efforts of your hapless - DRM confronted - helpers)

    It's clear that your Lcd is a character module, Port E drives RS & E, Port B provides Lcd data.

    Your initialization violates the classic HD44780 init. listing.   (that's the "standard" for 99% of such parallel-bus, text Lcds)   In addition - you follow display clear (which "homes the cursor") with a duplicate "home cursor" command.   Quaint but w/out merit.   (especially so as you fail to provide the increased delay imposed by 0x01 (home) command!)

    Appears that you enforce a "constant delay" upon each data write and command write.   That's a clear violation of HD44780 spec.

    Have you carefully, methodically "ohmed out" each/every connection between your MCU & the Lcd?   (you may delay this exercise until after you've brought your code into compliance w/Lcd spec)

    You state that, "cursor is displaying properly" which I believe to be incorrect.   Suspect you're seeing the cursor's "normal default behavior" - and that you have NO ability to "address the cursor" to any other display position - which (really) defines "proper cursor operation."

    Your "search/find" - then read/review of "that spec" - should assist your diagnosis of, "It's not working."