A problem in running character LCD via ATMEGA32A

Thread Starter

eric_s88

Joined Apr 20, 2011
158
Hi everyone!
I just wanted to show 2 statement (with a delay time between them) in a 2X16 character LCD via ATMEGA32A .. I use C language and Codvision compiler..
but when I run the circuit all of sections in line one in LCD get lighted (as shown in pic)
In order to test if the chip get programmed properly or not I used an LED in bit 0 at port A :) and I see LED works.. but LCD does not :(
where is the problem :( ??



and my codes:

Rich (BB code):
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Advanced
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : 
Version : 
Date    : 2011/10/14
Author  : www.Eca.ir *** www.Webkade.ir
Company : 
Comments: 


Chip type               : ATmega32A
Program type            : Application
AVR Core Clock frequency: 4.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 512
*****************************************************/

#include <mega32a.h>
#include <delay.h>

// Alphanumeric LCD Module functions
#include <alcd.h>

// Declare your global variables here

void main(void)
{
int i;
    for(i=0;i<=9;i++)
    {
    PORTA.0=1;
    delay_ms(350);
    PORTA.0=0;
    delay_ms(350);
    }
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
PORTD=0x00;
DDRD=0x00;

// Alphanumeric LCD initialization
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTC Bit 0
// RD - PORTC Bit 1
// EN - PORTC Bit 2
// D4 - PORTC Bit 4
// D5 - PORTC Bit 5
// D6 - PORTC Bit 6
// D7 - PORTC Bit 7
// Characters/line: 16
lcd_init(16);

while (1)
      {
      lcd_clear();
      lcd_gotoxy(0,0);
      lcd_putsf("state1");
      delay_ms(1000);
      lcd_putsf(" state2");
      delay_ms(1000);

      }
}
 

MrChips

Joined Oct 2, 2009
30,714
A lot has to do with lcd_init( ).
I have not used that particular library.
How does the library know which ports are connected to the LCD interface?
How does it know you are using PORTC?
Shouldn't PORTC be output? DDRC = 0xFF
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
I use Codevision , wich has a software , CodeWizard. in this software we can do a lots of micro settings..see the photo



do you think if I make that change > DDRC=0xFF.. the problem will be solved?
 

MrChips

Joined Oct 2, 2009
30,714
do you think if I make that change > DDRC=0xFF.. the problem will be solved?
No. I believe the library will init DDRC for you.
Try testing if it can find the LCD.

Rich (BB code):
// LCD module initialization
if (lcd_init(LCD_CHARS_LINE)!=0)
   {
   // The LCD is present
   }
else
   {
   // The LCD is not present
   };
Can you post a schematic of your circuit?
and what is the model number of your LCD?
 
Last edited:

Thread Starter

eric_s88

Joined Apr 20, 2011
158
I have tested this code in Proteus simulator, and there, everything was OK..
but in practical test, I cant get the statement in LCD :(
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
yes it was a mistake sry I am usuing 22pF caps, I now find the probolem.. :D It was sth wrong with fusebits programming:D now I have the statements on LCD , thank you
 

MrChips

Joined Oct 2, 2009
30,714
Now the next step is to double check the wiring on your breadboard.
Can you write code to make an LED flash? Have you done this and verified that it works?
You will need this to trouble shoot the circuit, unless you have an online debugger.
I do not see your ISP connections.

edit: Congrats! Now that you have it working, tell us what you had before and what changes you made to get it working. This forum works both ways. We help you, you help us.
 

Thread Starter

eric_s88

Joined Apr 20, 2011
158
thank you :)
yeaaah... in codvision software in section of programming FuseBits , fusebit called JTAGEN=0 was set as a default, that was wrong, I set SUT0=0 and CKOPT=0 fusebits on.. they are the fusebits that program my external oscillator ... that was all the problem :)
 
Top