[help] 16*2 character lcd problem
Mon Jul 28 2008, 07:37 pm
change this statement:
for(k=0; k<7; k++)
to
for(k-=0;k<6;k++)
as the loop will execute seven times (including zero). that would initiate a seventh command word to the LCD which might be causing problems
for(k=0; k<7; k++)
to
for(k-=0;k<6;k++)
as the loop will execute seven times (including zero). that would initiate a seventh command word to the LCD which might be causing problems
Thu Jul 31 2008, 06:50 pm
i think there is some problem in ready. when i tried to simulate this program in avr studio, the program stuck in ready function.
i think due to the commands 0x80 and 0xc0 makes the condition of loop in ready true.
when i didnot use ready, a cursor produced at first position in first line. but not charater still.
any suggestions?
i think due to the commands 0x80 and 0xc0 makes the condition of loop in ready true.
when i didnot use ready, a cursor produced at first position in first line. but not charater still.
any suggestions?
[ Edited Thu Jul 31 2008, 07:10 pm ]
Fri Aug 01 2008, 02:06 pm
finally it worked. i we (me and my friends) worte the code from the beginning from lcd tutorial and mazidi book. Without using ready(or busy) and any pointers, the new code worked. i still think that there is some problem in ready function in old code. Here is the new code ---
#include<avr\io.h> #include<util\delay.h> #define F_CPU 1000000UL #define dataport PORTA #define comm PORTB #define rs 0 #define rw 1 #define en 2 void datawr(char c) { DDRA = 0xFF; dataport = c; comm |= (1<<rs); comm &= ~(1<<rw); comm |= (1<<en); _delay_ms(50); comm &= ~(1<<en); } void command(char d) { DDRA = 0xFF; dataport = d; comm &= ~(1<<rs); comm &= ~(1<<rw); comm |= (1<<en); _delay_ms(50); comm &= ~(1<<en); } void intial(void) { int j; char b[]={0x38, 0x0c, 0x01, 0x84}; for(j=0; j<4; j++) { command(b[j]); _delay_ms(50); } } int main (void) { int i; char a[]="Hello"; DDRB = 0xFF; intial(); for(i=0;i<5;i++) { datawr(a[i]); _delay_ms(50); } while(1) { } }
[ Edited Fri Aug 01 2008, 02:08 pm ]
Fri Aug 01 2008, 02:58 pm
great work, rahul.
i will still find out what the problem was using the busy line and post it here.
till then :bye
i will still find out what the problem was using the busy line and post it here.
till then :bye
Fri Aug 01 2008, 03:40 pm
in custom characters, i am able to print them but i dont understand the purpose of word 'location' usin in the tutorial code.
one more thing --- when i dont use 0x06 (right increment command), the cursor still moves towards right after each aplabat.
void LCD_build(unsigned char [location, unsigned char *ptr){ unsigned char i; if(location<8){ LCD_command(0x40+(location*8)); for(i=0;i<8;i++) LCD_senddata(ptr[ i ]); } }
one more thing --- when i dont use 0x06 (right increment command), the cursor still moves towards right after each aplabat.
[ Edited Fri Aug 01 2008, 03:49 pm ]
Fri Aug 01 2008, 09:10 pm
location means which location on CGRAM, as you can have 8 custom characters so, you can give location from 0 to 7 to define where your custom char will be stored
Mon Aug 04 2008, 12:36 am
hi rahul,
I have succesfully interfaced the LCD using the busy line and also displayed custom characters. do look into it.
checked it for 8mhz internal oscillator.
P.S.:
ur previous code was fine except for some timing problems.
I have succesfully interfaced the LCD using the busy line and also displayed custom characters. do look into it.
checked it for 8mhz internal oscillator.
P.S.:
ur previous code was fine except for some timing problems.
Powered by e107 Forum System