Sajjadkhan
Full Member level 5
- Joined
- Sep 25, 2010
- Messages
- 307
- Helped
- 17
- Reputation
- 34
- Reaction score
- 16
- Trophy points
- 1,298
- Location
- Rawalpindi,Pakistan
- Activity points
- 4,199
I never used 4bit mode. I can but i have designed my PCB for 8 bit. As there is no library function for 8 bit so i tried to write functions my self. One problem i am having now is sending Array to sub function to display my message but nothing happens. The problem is in LCD_MSG() routine. The program jumps into this routine but never go in the while loop. I know i am doing wrong conversion but in C++ it is possible. can u hep me guys?
void LCD_INTT();
void LCD_CMMD();
void LCD_DTA();
void LCD_MSG(int,char[21]);
sbit EN at RC7_bit;
sbit RW at RC6_bit;
sbit RS at RC5_bit;
sbit pp at RC3_bit;
char message1[21] = " Testing LCD ";
void main()
{
TRISB = 0x00; //lcd port
TRISC = 0x00;
LCD_INTT();
LCD_MSG(128,message1); //128 = 80H = first line
XX: // LED toggling just to see if controller is working.
pp =0;
delay_ms(2000);
pp=1;
delay_ms(2000);
goto xx;
}
void LCD_INTT(){
EN = 0;
Delay_ms(100);
PORTB = 60;
LCD_CMMD();
Delay_ms(1);
PORTB = 15;
LCD_CMMD();
Delay_ms(1);
PORTB = 1;
LCD_CMMD();
Delay_ms(2);
PORTB = 6;
LCD_CMMD();
Delay_ms(1);
}
void LCD_MSG(int R,char Message[21]){
int i=0;
int Asci;
PORTB = 65; //65=A, put to check if this is being printed or not. YES.
LCD_DTA();
PORTB = R;
LCD_CMMD();
While(i!=21)
{
Asci = Message;
i++;
PORTB = Asci;
//portb= 66; added to see if program is jumping in he loop or not. but NO.
LCD_DTA;
Delay_ms(1);
}
}
void LCD_CMMD(){
RS = 0;
RW = 0;
EN = 1;
Delay_ms(1);
EN = 0;
}
void LCD_DTA(){
RS = 1;
RW = 0;
EN = 1;
Delay_ms(1);
EN = 0;
}
void LCD_INTT();
void LCD_CMMD();
void LCD_DTA();
void LCD_MSG(int,char[21]);
sbit EN at RC7_bit;
sbit RW at RC6_bit;
sbit RS at RC5_bit;
sbit pp at RC3_bit;
char message1[21] = " Testing LCD ";
void main()
{
TRISB = 0x00; //lcd port
TRISC = 0x00;
LCD_INTT();
LCD_MSG(128,message1); //128 = 80H = first line
XX: // LED toggling just to see if controller is working.
pp =0;
delay_ms(2000);
pp=1;
delay_ms(2000);
goto xx;
}
void LCD_INTT(){
EN = 0;
Delay_ms(100);
PORTB = 60;
LCD_CMMD();
Delay_ms(1);
PORTB = 15;
LCD_CMMD();
Delay_ms(1);
PORTB = 1;
LCD_CMMD();
Delay_ms(2);
PORTB = 6;
LCD_CMMD();
Delay_ms(1);
}
void LCD_MSG(int R,char Message[21]){
int i=0;
int Asci;
PORTB = 65; //65=A, put to check if this is being printed or not. YES.
LCD_DTA();
PORTB = R;
LCD_CMMD();
While(i!=21)
{
Asci = Message;
i++;
PORTB = Asci;
//portb= 66; added to see if program is jumping in he loop or not. but NO.
LCD_DTA;
Delay_ms(1);
}
}
void LCD_CMMD(){
RS = 0;
RW = 0;
EN = 1;
Delay_ms(1);
EN = 0;
}
void LCD_DTA(){
RS = 1;
RW = 0;
EN = 1;
Delay_ms(1);
EN = 0;
}