Discussion in "AVR Discussion Forum" started by    rahuljin    Jul 23, 2008.
Mon Jul 28 2008, 07:37 pm
#11
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
Tue Jul 29 2008, 01:34 am
#12
corrected, but still nothing.
Thu Jul 31 2008, 06:50 pm
#13
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?


[ Edited Thu Jul 31 2008, 07:10 pm ]
Thu Jul 31 2008, 08:19 pm
#14
can you try the program i gave in my tutorial?
Fri Aug 01 2008, 02:06 pm
#15
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
#16
great work, rahul.
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
#17
in custom characters, i am able to print them but i dont understand the purpose of word 'location' usin in the tutorial code.

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
#18
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
#19
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.
Attachment
Mon Aug 04 2008, 01:02 am
#20
here is a snapshot:


Get Social

Information

Powered by e107 Forum System

Downloads

Comments

FrankTrelm
Tue May 14 2024, 10:39 am
BillyTum
Tue May 14 2024, 09:08 am
Loganbag
Tue May 14 2024, 04:05 am
MichaelMog
Tue May 14 2024, 03:58 am
ThomasGaxaW
Mon May 13 2024, 05:33 pm
RobertInfup
Mon May 13 2024, 04:28 pm
Joshuatem
Mon May 13 2024, 08:30 am
RaymondPex
Mon May 13 2024, 03:24 am