|
|
View previous topic :: View next topic |
Author |
Message |
jaethelegend Guest
|
About LCD control |
Posted: Sat Jun 06, 2009 7:01 am |
|
|
Hi, I was originally using a full PORT with all 8 ports available to control a LCD display, connecting RA0~2 to RS,RW,EN and RA4~7 to D04~7.
It worked fine.
Now, i tried to practice different ways of doing it for later use by
connecting RA0~3 to D4~7 and RS to D5, RW to D6, R7 to EN.
I guess the biggest difference between first coding scheme and the second coding scheme is that in first coding scheme, i controlled(outputted) the entire 7 required bits to the LCD at a time. In second time, I played with the output ports before i pulsed enable signal.
below is quick code example
First Scheme which worked fine.
Code: | void Busy_Check(){
int8 high_nibble, low_nibble;
do{
LCD_TRIS = 0b10000000;
LCD_PORT = 0b00000110; // RS=0, RW=1 EN=1
delay_us(14);
high_nibble=LCD_PORT;
delay_us(14);
LCD_PORT = 0b00000010; //RS = 0, RW = 1, EN = 0
LCD_PORT = 0b00000110; //RS = 0, RW = 1, EN = 1
delay_us(14);
low_nibble = LCD_PORT;
delay_us(14);
LCD_PORT = 0b00000010; // RS = 0, RW = 1, EN = 0
}while(high_nibble&0x80);
LCD_TRIS = 0x00;
LCD_PORT = 0x00;
}
|
Second scheme which didn't work
Code: |
void busy_check(void){
int8 high_nibble, low_nibble;
do{
LCD_TRIS = 0b10000000;
LCD_PORT = 0b00000000; // RS=0, RW=1 EN=1
R_W = 1;
E_N = 1;
delay_us(14);
high_nibble=LCD_PORT; //LCD로 부터 나오는 상위 니블 리드.
delay_us(14);
E_N = 0;
E_N = 1;
delay_us(14);
low_nibble = LCD_PORT;
delay_us(14);
E_N = 0; // RS = 0, RW = 1, EN = 0
}while(high_nibble&0x80); //D7 이 1이면 받을 준비가 안됨.
LCD_TRIS = 0x00;
LCD_PORT = 0x00;
}
|
Thank you, I appreciate your help |
|
|
Steve H Guest
|
|
Posted: Sat Jun 06, 2009 9:44 am |
|
|
You realize that in the 4 bit nibble mode - you have to go through a special initialize sequence for the LCD? You can find this in a bunch of places (try the CCS examples, Google or the LCD data sheet) or look at some of my code here,
http://geocities.com/hagtronics/wwvb.c
HTH - Steve H. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
jaethelegend Guest
|
|
Posted: Sun Jun 07, 2009 9:46 pm |
|
|
Thanks guys! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|