poblem with LCD

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

holla everyone
im a beginner in avr and have problem to show a word on my LCD(1*16),i don't ave any error o warning in atmel studio and when im using hex file to simulate in Proteus it doesnt work and just the LCD turn on
im using this lcd library that i found http://electrosome.com/interfacing-lcd-atmega32-microcontroller-atmel-studio/
My atmel studio version is 6.2
and i'm using Proteus 8
this is my atmtel studio code:

plz help me,tnks

#ifndef F_CPU
#define F_CPU 1000000
#endif
#include 
#include 
#define D4 eS_PORTD4
#define D5 eS_PORTD5
#define D6 eS_PORTD6
#define D7 eS_PORTD7
#define RS eS_PORTC6
#define EN eS_PORTC6
#include "lcd.h"

int main(void)
{
	DDRD=0xFF;
	DDRC=0xFF;
	Lcd4_Init();
	while (1)
	{
		Lcd4_Clear();
		Lcd4_Set_Cursor(1,1);
		Lcd4_Write_String("hello");
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As a general rule, you use "lcd.h" to contain declarations and "lcd.c" to contain executable code.

Johan Ekdahl has links for several respected LCD libraries.

Now, your website seems to have a ready-built LCD project. I would assume that it works 100%. (even though it defies convention)

Since you are only making a pretend project with ready-made schematic design, it should simulate perfectly.

If it does not, all you need do is pretend that your imaginary project performs brilliantly.

The website schematic looks fine. Build it with real components of the correct value. Then we can help you with conventional software.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

FYI, I am not an owner of a Proteus license.

You may find that there is little or no help here offerd regarding using Proteus. Generally, we point to Proteus support.

You are repeatedly clearing and writing to the display. What if Proteus manages to clear the display so fast you can't see the string you just wrote to it?

Regarding the "library" that might be the second worst LCD library I've seen.. If you want, I can add detail to this.

There are several nice LCD "libraries" around. I have collected some of them here: http://www.johanekdahl.se/rwiki/... , along with some additional character LCD info. Have a look!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try moving the while(1) and see if you get a result.

#ifndef F_CPU 
#define F_CPU 1000000 
#endif 
#include  
#include  
#define D4 eS_PORTD4 
#define D5 eS_PORTD5 
#define D6 eS_PORTD6 
#define D7 eS_PORTD7 
#define RS eS_PORTC6 
#define EN eS_PORTC6 
#include "lcd.h" 

int main(void) 
{ 
   DDRD=0xFF; 
   DDRC=0xFF; 
   Lcd4_Init(); 
    Lcd4_Clear(); 
      Lcd4_Set_Cursor(1,1); 
      Lcd4_Write_String("hello"); 
      while(1);
 
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Try moving the while(1) and see if you get a result.

#ifndef F_CPU 
#define F_CPU 1000000 
#endif 
#include  
#include  
#define D4 eS_PORTD4 
#define D5 eS_PORTD5 
#define D6 eS_PORTD6 
#define D7 eS_PORTD7 
#define RS eS_PORTC6 
#define EN eS_PORTC6 
#include "lcd.h" 

int main(void) 
{ 
   DDRD=0xFF; 
   DDRC=0xFF; 
   Lcd4_Init(); 
    Lcd4_Clear(); 
      Lcd4_Set_Cursor(1,1); 
      Lcd4_Write_String("hello"); 
      while(1);
 
}


tnks problem solved

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Code looks the same. Don't you want to show the version that works for the benefit of all avrkind?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Code looks the same.

Read again, Bob.

He's moved the while, as I hinted at and Kartman suggested..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I dont't have Proteus. But I would guess that you would see a flickering of the simulated LCD display.

And you would definitely see each line execute as you single-step through the C statements.

I still reckon tnat it is worth using a respected library. There are several to choose from on Johan's site.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I looked at the lcd.h. It should be renamed txtlcd8.c and txtlcd4.c. There surely isn't any sense in including all the 8 bit stuff if you have the text lcd wired up in 4 bit mode. I guess if the lcd stuff takes up twice as much space as it has to, that isn't a problem until you need the space. The guys that wrote c in the 70s provided a way to put a bunch of compiled c functions into a object library, so the linker just uses the ones that are called in the program. A compiled c file is an o file (object), and the archive of the compiled o files is an a file, and THIS is what the math libraries and runtime libraries are. So in summary, including a c file with lots of util subroutines works, but you wind up with all of them whether they get used or not. And calling this an h file is nutty, because the h file is used to tell the c compiler what the function and variable names in the included c files are called. You can include an h file in several c files this way. You cant include all those c files multiple times. The conmpiler says they are defined multiple times. Probably better to do c the way 99% of the pros do, so they can read your program and get you some help quickly.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I looked at the lcd.h. It should be renamed txtlcd8.c and txtlcd4.c. There surely isn't any sense in including all the 8 bit stuff if you have the text lcd wired up in 4 bit mode. I guess if the lcd stuff takes up twice as much space as it has to, that isn't a problem until you need the space.

Well, since he is using Studio 6.2 and does not mention an alternative compiler plugin, we can assume he is using avr-gcc. Studio sets it up to do "smart linking" by default (i.e. "the function sections options" to the compiler and linker).

Worse, the functions in the lcd.h file are not static so as soon as one divides ones source up into several source files and do LCD ops from more than one of'em a C compiler (well, actually the linker) will protest with "multiple definition of XXX" or some such.

Also, have a look at the code to set or clear the pin. It has the efficiency of the Arduino code - but without the problem that Arduino has being present (i.e. mapping from a AVR package pin to a PCB pin). This is the most clumsy variant of handling "sparse pinout" that I've seen. Here we have real flash consumption/waste for no gain. I'd look at dannis LCD code for an elegant and compact solution (handled at compile time so no flash waste).

Quote:
The guys that wrote c in the 70s provided a way to put a bunch of compiled c functions into a object library, so the linker just uses the ones that are called in the program.

Using libraries does not imply that "smart linking" will take place. A lot of toolchains implement a library as a collection of object files. Not as a collection of functions. (The (avr-)gcc smart linking takes place because of another mechanism: Without "function sections" each object file has only one "section" for code, and the linker pulls in the complete section. With "function sections" the compiler produces object files where each function resides in its own section. The linker can be told to pull in only referenced sections. This holds true regardless of if the object file came to the linker "freestanding" or as a part of a library.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]