Jump to content


  • Content Count

  • Joined

  • Last visited

  1. Hi Started Working with Stellaris Launchpad EK-LMF120XL,I tried Interfacing with LED and now started with LCD. I am trying to print a single character,I unable to do it,i am posting my code please have a look .tell me where i am going wrong, Thanks and Regards Karteek LCD code for single character #include "lm4f120h5qr.h" /* Enable/Disable Pin */ #define LCD_Enable GPIO_PORTC_DATA_R|0x40; // To Enable LCD// #define LCD_Disable() GPIO_PORTC_DATA_R&(~0x40);// To Disable LCD// /* Read Write Pin (R/W) */ #define LCD_Enable_Read() GPIO_PORTC_DATA_R|0x20; // To Enable LCD Read Operation// #define LCD_Enable_write GPIO_PORTC_DATA_R&(~0x20); // To Enable LCD Write Operation// /* Pin RS (Register Select)*/ #define LCD_Enable_Display_Data() GPIO_PORTC_DATA_R|0x10; // When this signal is '1' = It accepts data to be displayed/ // When this signal is '0' = It accepts instructions for the LCD like setting font, cursor position etc// #define LCD_Enable_instruction GPIO_PORTC_DATA_R&(~0x10); void portB_init(); void portC_init(); void write_LCD(); void Delay(); void latch(); int main() { portB_init();// Initialization of port B// portC_init();// Initialization of port C// write_LCD(); return 0; } void portB_init() { // SYSCTL_GPIOHBCTL_R|=0X2u; SYSCTL_RCGCGPIO_R|=0x2u; GPIO_PORTB_DIR_R=0xFFu; GPIO_PORTB_DR8R_R|=0xFFu; GPIO_PORTB_DEN_R=0xFFu; } void portC_init() { //SYSCTL_GPIOHBCTL_R|=0x04u; SYSCTL_RCGCGPIO_R|=0x4u; GPIO_PORTC_DIR_R=0x70u; GPIO_PORTC_DR8R_R|=0x70u; GPIO_PORTC_DEN_R=0x70u; } void write_LCD() { int i=0; LCD_Enable_instruction; LCD_Enable_write; LCD_Enable; Delay(); GPIO_PORTB_DATA_R=0x38u; //This instruction will Enable 8-bit Databus, Set 2 lines, and Select font size 5x7// for(i=0;i<4;i++) { latch(); } GPIO_PORTB_DATA_R=0x0fu;//It will display the characters, will display the cursor and it will blink.// latch(); GPIO_PORTB_DATA_R=0x01u;// clear the entire display. And bring your cursor to position 0. Or home position.// latch(); GPIO_PORTB_DATA_R=0x80u;// to select line 1// LCD_Enable_Display_Data(); GPIO_PORTB_DATA_R=0x30u;//data to display // latch(); } void latch() { LCD_Enable; Delay(); LCD_Disable(); Delay(); } void Delay() { int count=0; while(count<10000000) { count++; } }