Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.
We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.
Thank you for your understanding.
hi, guys I have a doubt regarding interfacing lcd to arm7. I have an lpc2148 development board. This board did have a lcd interfacing example. I also have another program I got from internet. I see that the function to initialize the lcd are written in different ways in both the examples. In the example I got with the board the "void lcd_init()" is little complex. But the other example I got from internet the has "void init_lcd( void )" written in a simple way. I have edited and tried the codes in different ways and I see only the code I received with the board works. I am new to ARM, but I don't think this should be correct, we should be able to make new codes. Hoping someone can understand my doubt.
CODE THAT CAME WITH THE DEVELOPMENT BOARD
#include <LPC214x.H> #define LCD_RS (1<<10) #define LCD_RW (1<<12) #define LCD_EN (1<<13) #define LCD_D4 (1<<20) #define LCD_D5 (1<<21) #define LCD_D6 (1<<22) #define LCD_D7 (1<<23) #define LCD_DATA_MASK (LCD_D7|LCD_D6|LCD_D5|LCD_D4) #define LCD_IOALL_MASK (LCD_D7|LCD_D6|LCD_D5|LCD_D4|LCD_RS|LCD_EN|LCD_RW) //*************************** void enable_lcd(void) { unsigned int i; IOSET0 = LCD_EN; for (i=0;i<400000;i++); IOCLR0 = LCD_EN; } //************************** void lcd_init() { unsigned int i; PINSEL1 = 0x00000000; IODIR0 |= LCD_IOALL_MASK; for (i=0;i<1000;i++); IOCLR0 = (LCD_IOALL_MASK); IOSET0 = (LCD_D5|LCD_D4); enable_lcd(); for (i=0;i<100;i++); IOCLR0 = (LCD_IOALL_MASK); IOSET0 = (LCD_D5|LCD_D4); enable_lcd(); for (i=0;i<100;i++); IOCLR0 = (LCD_IOALL_MASK); IOSET0 = (LCD_D5|LCD_D4); enable_lcd(); delay(10000); while(busy_lcd()); IOCLR0 = (LCD_IOALL_MASK); IOSET0 = (LCD_D5); enable_lcd(); delay(10000); while(busy_lcd()); lcd_write_control(0x28); lcd_write_control(0x0C); lcd_write_control(0x06); lcd_write_control(0x01); lcd_write_control(0x0F); lcd_write_control(0x01); for (i=0;i<100000;i++); } //***************************** char busy_lcd(void) { unsigned long busy_status; unsigned int i; IODIR0 &= LCD_DATA_MASK; IOCLR0 = LCD_RS; IOSET0 = LCD_RW; IOSET0 = LCD_EN; for (i=0;i<1000;i++); busy_status = (IOPIN1 & 0x80000000); if(busy_status == 0x80000000) { IOCLR0 = LCD_EN; IOCLR0 = LCD_RW; IODIR0 |= LCD_IOALL_MASK; return 1; } else { IOCLR0 = LCD_EN; IOCLR0 = LCD_RW; IODIR0 |= LCD_IOALL_MASK; return 0; } } //****************************** void lcd_out_data4(unsigned char val) { IOCLR0 = (LCD_DATA_MASK); IOSET0 = (val<<20); } //********************************** void lcd_write_byte(unsigned char val) { lcd_out_data4((val>>4)&0x0F); enable_lcd(); lcd_out_data4(val&0x0F); enable_lcd(); delay(100000); // while(busy_lcd()); } //********************************** void lcd_write_control(unsigned char val) { IOCLR0 = LCD_RS; lcd_write_byte(val); } //********************************** void lcd_write_ascii(unsigned char c) { IOSET0 = LCD_RS; lcd_write_byte(c); } //******************************** void goto_cursor(unsigned char i) { i |= 0x80; lcd_write_control(i); } //******************************* void lcd_print(unsigned char* str) { int i; for (i=0;i<16 && str[i]!=0;i++) { lcd_write_ascii(str[i]); } } //****************************** void delay(unsigned long int count1) { while(count1 > 0) {count1--;} }
I will copy the other code in the below thread
Check the LCD Initialization section in www.ocfreaks.com/.../
Thanks, I will go through the link
Thanks Foster, the link did help me.