Atmega644 Lcd Interfacing issue

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

Hi everyone;

                     I am working on a project using ATMEGA644 DIP. In this I have written a program for LCD interface which is working fine in Proteus simulation, but on the hardware it is not giving me any response on LCD. As I observed may be my micro controller is not set on the external clock or it can be any other issue also, same program is working fine with ATMEGA32 with 16 Mhz external oscillator. Please help me out. Thanks in advance.

Last Edited: Thu. Aug 31, 2017 - 08:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Show code
Show fuse values
Show schematic

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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

Instructions on How To Post Code and How To Post Images (eg, schematics)

 

Here: http://www.avrfreaks.net/comment...

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

Thanks for the response. Here is my my code.

 

 

// My LCD library

 

#include <avr/io.h>

#include <util/delay.h>

#include <stdlib.h>

#define rs PC0

#define en PC1

 

void lcd_displays (char *str)

{

unsigned int sd[7]={0x02,0x28,0x0F,0x06,0x80,0x01};

char ar1=0,ar2=0;

char ch1=0,ch=0;

 

for (unsigned int k=0;sd[k]!=0;k++)

{

ar1=sd[k];

ar2= ar1 & 0xF0;

 

PORTC=ar2;

PORTC&=~(1<<rs);

PORTC|=(1<<en);

_delay_ms(1);

PORTC&=~(1<<en);

_delay_ms(1);

ar2= ((ar1<<4) & 0xF0);

PORTC=ar2;

PORTC&=~(1<<rs);

PORTC|=(1<<en);

_delay_ms(1);

PORTC&=~(1<<en);

_delay_ms(1);

}

 

for (unsigned int j=0;str[j]!=0;j++)

{

ch = str[j];

ch1= ch & 0xF0;

PORTC=ch1;

PORTC|=(1<<rs);

PORTC|=(1<<en);

_delay_ms(1);

PORTC&=~(1<<en);

_delay_ms(1);

ch1= ((ch<<4) & 0xF0);

PORTC=ch1;

PORTC|=(1<<rs);

PORTC|=(1<<en);

_delay_ms(1);

PORTC&=~(1<<en);

_delay_ms(1);

}

_delay_ms(1);

}

 

 

 

// Main code

 

int main()

{

        DDRC = 0XFF;

        lcd_displays("PRINT ON LCD");

        _delay_ms(5000);

}

 

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

Your LCD is connected to PortC which is also the JTAG port which you've left enabled.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

1.  Excellent strategy to test first with Proteus before assembling hardware.

2.  Even better that you have shown your fuses.

3.  You have chosen the default fuses.   This means JTAGEN.

4.  You are using PC4, PC5 which are JTAG pins.

5.  Either disable JTAG in software with JTD.

6.  Or remove the JTAGEN fuse.

 

Some general advice:

7.  use CODE window when posting code

8.  format the code neatly.   this makes your code attractive to read.   Most importantly,  you will find it easier to understand.

 

David.

 

p.s.  read the datasheet to see how to use JTD.

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

Thanks for reply. Sorry for asking this how should I disable JTAG. I am new to this micro controller.

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

Dear All;

             Thank you very much issue is resolved by disabling JTAG.

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

david.prentice wrote:
1.  Excellent strategy to test first with Proteus before assembling hardware.

Shame that Proteus doesn't spot the JTAG issue - I'd say that's a pretty serious flaw.

 

5.  Either disable JTAG in software with JTD.

6.  Or remove the JTAGEN fuse.

Or, better still use the JTAG pins for JTAG!!

 

Having a device with on-chip debug and not using it is pure folly. You are tying your own hands behind your back!

 

Some general advice:

7.  use CODE window when posting code

As was explained in #3

 

8.  format the code neatly.   this makes your code attractive to read.   Most importantly,  you will find it easier to understand.

+10

 

 

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

One more thing I required to know. How to set atmega644 for using external crystal on 16 Mhz frequency.

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

Abhay02 wrote:
How to set atmega644 for using external crystal on 16 MHz frequency.

David's PS answers this:

david.prentice wrote:
p.s.  read the datasheet to see how to use ... 

 

Reading the datasheet should be your first step in finding out how to use any feature of any chip!

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

Hi David;

             I have tried after making CKSEL3..0 pins disable but still micro controller is not using external crystal.

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

awneil wrote:
Shame that Proteus doesn't spot the JTAG issue - I'd say that's a pretty serious flaw.
On the contrary - I applaud Proteus for getting the simulation right - it spotted that JTAGEN was enabled so prevented C4..7 being using as normal IO. (just like would have happened in the real silicon).

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

But he said it worked in Proteus?

 

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

Oops, must learn to read, must learn to read .... blush

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

Abhay02 wrote:
I have tried after making CKSEL3..0 pins disable but still micro controller is not using external crystal.

How are you determining that it is not using the external crystal?

 

Tell us the precise fuse values (preferably as read out in hexadecimal).

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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]

Last Edited: Thu. Aug 31, 2017 - 11:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

 

When i am printing a long string on LCD it's speed is slow but when I am using atmega32 it is prining the same string in good speed with same crystal and same program.

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

Those fuse values seem to be for internal RC oscillator.

Double check with this: http://www.engbedded.com/fusecalc

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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

I have made CKSEL 3..0 as 0000 but still not getting the required output at 16Mhz.

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

I have made changes in fuse values and my both micro controllers are showing "Programming failed". 

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

That could be bad or really bad. Locate the tutorial "Resurrecting a bricked AVR" (or a title similar to that) in the Tutorials forum here at AVRfreaks and read.

Unless you've messed with the SPIEN fuse there are relatively simple ways to fix it.

Lesson to be learned: Do not fiddle with fuses unless you are absolutely sure of what you are doing. (If you need to ask yourself "How do I know if I'm sure?", then you're not.)

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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

Can you please tell me the exact fuse values to set it on External crystal of 16 Mhz??

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

 

While trying to set the atmega644 on external crystal I messed up with fuse values. Now I am getting this error. Is there any solution available for this issue??

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

Abhay02 wrote:
Now I am getting this error. Is there any solution available for this issue??

 

Three posts up I told you to go locate a tutorial here on AVRfreaks and read it. With 99% certainty it applies to your problem. In fact, the situation you're in is so common someone decided to instead of answering every time the question was asked, to write a tutorial covering it. Depending on things unknown to both us and you ATM, there is no one distinct solution to your problem. It will be a matter of trial and error. Read the tutorial for the details.

 

No, no-one will re-type the test of that tutorial just so that you will not need to locate and read it in it's current place.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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

Abhay02 wrote:

Can you please tell me the exact fuse values to set it on External crystal of 16 Mhz??

For the ATmega644, and everything default except clock source which was selected to be

 

 Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time: 16K CK + 4.1 ms; [CKSEL=1111 SUT=10]

 

 

engbedded.com computes the fuse byte values to:

 

Low: 0x7F

High: 0x99

Extendec: 0xFF

 

But this leaves your CLKDIV8 switch still programmed, so the ATmega644 will run 8 times slower than the crystal. clearing the CLKDIV8 engbedded.com computes

 

Low: 0xEF

High: 0x99

Extendec: 0xFF

 

But, since you likely have "bricked" your AVR (by programming some unknown but really bad fuse values) you first need to try to fix that, as described in the thread i linked to above.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"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]

Last Edited: Fri. Sep 1, 2017 - 11:22 AM