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 i'm kinda new here but this is my code for 16x2 Lcd It was made with Keil uVision, Enjoy
#include <REGX52.H> #define LCD_data P2 #define LCD_rs P1_0 #define LCD_rw P1_1 #define LCD_en P1_2 void LCD_busy(void); void LCD_poweron(void); void LCD_command(unsigned char var); void LCD_senddata(unsigned char var); void LCD_sendstring(unsigned char *var); void LCD_init(void); void main(void) { unsigned char msg[] ="Learning"; LCD_poweron(); // 15ms delay LCD_init(); LCD_command (0x80); // Set CGRAM adress,data is Avaible from uC LCD_sendstring(msg); while(1); } void LCD_busy() { unsigned char i,j; for(i=0;i<50;i++) for(j=0;j<255;j++); } void LCD_poweron() { unsigned int i; for (i=0;i<22500; i++); } void LCD_command(unsigned char var) { LCD_data = var; //Function set: 2 Line, 8-bit, 5x8 dots LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in instruction register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command } void LCD_sendstring(unsigned char *var) { while(*var) //till string ends LCD_senddata(*var++); //send characters one by one } void LCD_senddata(unsigned char var) { P2 = var; //Function set: 2 Line, 8-bit, 5x7 dots LCD_rs = 1; //Selected data register LCD_rw = 0; //We are writing LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command } void LCD_init(void) { LCD_data = 0x38; //Function set: 2 Line, 8-bit, 5x8 dots LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x0F; //Display on, Curson blinking command LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x01; //Clear LCD LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x06; //Entry mode, auto increment with no shift LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; //Enable H->L LCD_busy(); }
YES THE CODE IS VERY VERY VERY GOOD. I TRIED IT AND I SAY IT WORKS 257%
VERY VERY GOOD.
VERY VERY VERY GOOD...IT WORKS 257%
Oh, yeah.
Thx 4 t code.
I can confirm. It works. 1000%