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(); }
i put this in the code
#include < hw_delay.h > but it did not work. what is wrong?
the problem is that you are a student (I hope!!!) that does not know the basic of the C language. Did you cheat in your last C exam, too?
In what way, precisely, did it "not work"?
"what is wrong?"
You have not supplied nearly enough information to even guess!
#include < hw_delay.h >
s/< /</ s/ >/>/
it did not work .there was nothin g on the display.
Surely, if the problem were with the syntax of the #include, that would give compiler errors?
Did the project build & download successfully with no errors and no warnings?
no. i get somethin about cannot find file.
Well, Obviousy the code isn't going to work if it didn't even build - is it?!
"i get somethin about cannot find file."
Someone should make a post recommending how to make the file findable.
Or even better:
s/< /"/ s/ >/"/
User-supplied header files should use
#include "myfile.h"
since the compiler isn't expected to look in the system-supplied include directories for the file.
i dont under stand.
i think it cannot find hw_delay.h. it is not on my c drive. where is it?
Is there a reason why it should be on your C: drive?
If no one have placed it there, I would find it quite more likely that it isn't on your C: drive...
where is it?
I have it! Hipi!