Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD 4bit mode interfacing with ATMEGA16/32 . Not working with external Crystal

Status
Not open for further replies.

gelectron

Junior Member level 2
Joined
Aug 10, 2012
Messages
23
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,283
Activity points
1,416
Dear all,

I have made LCD 4 bit program for interfacing with atmega32a by Atmel studio.And tried out simulation in Proteus.
It works with perfectly in the mode of Internal clock mode. Not working when put it in external crystal mode (ie, Fusebit CKSEL 1010 -11110)
i am uploaded the whole program including proteus file please help me . I am banging my head from the morning .:bang:
 

Attachments

  • lcd avr 4bit.rar
    45 KB · Views: 56

Hi,

I don´t see any crystal. I don´t see it´s frequency. I don´t see it´s capacitors.
I don´t see a schematic at all.

If you think the problem is because of the crystal, then why don´t you give use informations about the crystal?

Klaus
 

oh sorry , I wrongly uploded the Zip file without connecting crystal and cappaictor in the above circuit realy sorry . i used a crystal 12 MHz with two 22pf cappacitor as shown below
https://obrazki.elektroda.pl/4897824300_1484710245.png

I reinstalled the Proteus program .After that the said program run correctly where i have get the display at the LCD.

But the program not run in real hardware . i rechecked the connections ,And tested with an LED blinking program which working perfectly .
I also checked with other 8 bit LCD program from google and working perfectly .
But mine not working :oops:

I am using usbAsp (slow mode-SCK Jumper-connected) programmer .
 

Dear all what wrong with this code ,properly work in proteus but not in hardware.
Code:
/*

#define F_CPU 12000000UL
#include <avr/io.h>
#include<util/delay.h>
#define LCDPORT PORTC   // Renaming the PORTD to LCDPORT
#define RS PC2          // Renaming the RS pin to 2 
#define E PC3            // Renaming the E to number 3
#define LINE2 lcd_cmd(0xc0);  
 void latch(void)  // used to a high to low pulse the pin E
 {
	 PORTC |= ~(1<<E);  // here we give a high to PORTD.3
	_delay_ms(1);
	 PORTC |= (1<<E);   // Here we give a LOW to PORTD.#
 }
 
 
 
 
 void lcd_cmd(unsigned char c)   // used to send the command / Instruction to the lcd port
 {
	 PORTC |= ~(1<<RS);    // send a '0' value to select to send command
	 _delay_ms(1);
	 LCDPORT = c & 0xf0;  //  send  the command c only 4 bit by masking the lower bit
	 latch();
	 _delay_ms(1);
	 LCDPORT =  (c << 4); // giving the lowerbit  by shifting the 4 bit to left
	 latch();
 }
 
 void lcd_data(unsigned char c)
 {
	 PORTC |= (1<<RS);    // send 1 to send data
	 _delay_ms(1);
	 LCDPORT = c & 0xf0| 0x4; //send  the data  only  4 bit by masking the lower bit and also making the RS pin high by giving 0x04 .
	 _delay_ms(1);
	 latch();
	 
	 LCDPORT = (c << 4)| 0x4; ; // giving the lower bit  by shifting the 4 bit to left
	 latch();
 }
 
  void lcd_init()
  {
	  _delay_ms(20);
	  lcd_cmd(0x30);  //as per data sheet
	  _delay_ms(1);
	  lcd_cmd(0x30);    //as per data sheet
	  _delay_us(100);
	  lcd_cmd(0x32);    //as per data sheet
	  _delay_ms(4);
	  lcd_cmd(0x28);            // Function set (4-bit interface, 2 lines, 5*7Pixels)
	  lcd_cmd(0x28);            // Function set (4-bit interface, 2 lines, 5*7Pixels)
	  lcd_cmd(0x0c);            // Make cursorinvisible
	  lcd_cmd(0x6);            // Set entry Mode(auto increment of cursor)
  }
 
  void string(const char *q)    // used to send single charcter to display the lcd
  {
	  while (*q) {
		  lcd_data(*q++);
	  }
  }
 
 
void main(){
	  _delay_ms(50);
	 DDRC = 0xff;
	lcd_init();
 	string("hello ");
	LINE2
	string("good displaying ");
	while(1);
}


Capture.PNG
 

Post your exact hardware circuit. Show the fuses that you have written to the chip.
 

The post #4 has my actual circuit and the fuse bit is Capture.PNG
 

Hi,

The post #4 has my actual circuit
I doubt that this exactely is your hardware setup: Power supply, decoupling capacitors, reset circuit...

Klaus
 

2,3 days tried out .the same sir .

And i taken some of Lcd interfacing circuit with including hex program ,most of them works correctly in that hardware .
I am using atmel studio 6
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top