Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MikroC code for 8bit LCD.

Status
Not open for further replies.

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;
}
 

Code:
void LCD_INTT(){
EN = 0;
Delay_ms(100);
[B][I][U]PORTB = 60;[/U][/I][/B]   //What is this what i thought you want to send Hex 0x38 value but by mistaken you are sending 0x3C(60)
LCD_CMMD();
Delay_ms(1);
[B][I][U]PORTB = 15;[/U][/I][/B]  //Display ON Cursor Blinking .. this part is Okay
LCD_CMMD();
Delay_ms(1);
PORTB = 1;
LCD_CMMD();
Delay_ms(2);
PORTB = 6;
LCD_CMMD();
Delay_ms(1);
}

What 60 to 56 it will work..

Hope you understand what i want to say...

Hope this will help you..
 

Code:
void LCD_INTT(){
EN = 0;
Delay_ms(100);
[B][I][U]PORTB = 60;[/U][/I][/B]   //What is this what i thought you want to send Hex 0x38 value but by mistaken you are sending 0x3C(60)
LCD_CMMD();
Delay_ms(1);
[B][I][U]PORTB = 15;[/U][/I][/B]  //Display ON Cursor Blinking .. this part is Okay
LCD_CMMD();
Delay_ms(1);
PORTB = 1;
LCD_CMMD();
Delay_ms(2);
PORTB = 6;
LCD_CMMD();
Delay_ms(1);
}

What 60 to 56 it will work..


Hope you understand what i want to say...

Hope this will help you..

Its for initializing the lcd. LCD is jhd204A, controller ks0066.these are decimal numbers. u can convert them in hex. this not an issue though, they are working fine.
I ran this lcd many times using 8051. in that it was simple to print message using DPTR register but i am new to pic and its damn complicated in C.

---------- Post added at 00:36 ---------- Previous post was at 00:35 ----------

https://www.hantronix.com/down/ks0066u.pdf

---------- Post added at 00:43 ---------- Previous post was at 00:36 ----------

Also plz explain this in 4 bit mode:


sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
---------------------------------------------
I understand this above code as pin assignment. but i don understand the below code.
---------------------------------------------
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;



Its given here in example 10. **broken link removed**
 

I think MikroC a bit difficult to use ,i have made such a program using MPLAB with C18 compiler and its just a child's play just simple leds on off
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top