interfacing 74595 to 16x2 lcd in 8 bit mode

Guest #4923605
Oldham P. wrote:
> I have made some code to perform this task but i see no out come on the
> lcd. my hardware is ok .

There is too much information at once, I cannot handle this.
#4925569
I just can guess that pin 37 of your AtMega is data out, which should go 
to pin 14 at 74xx595 (serial data in).
Pin 7 could be connected to data in of another 74xx595, which isn't used 
in your configuration.
OP #4925722
Ok. Thanks.Now forgetting about pin7 ,what can be done about software?
incidentally this hardware works ok with another programmed ic atmega32, 
but it dose not work with the one I have programmed.
#4925740
Look, the information you're providing is extremely sparse. It is almost 
impossible to help.

Nobody knows anything about the code you are running on the your atmega.
How do you expect anybody to be able to say something about software 
then?

Also: are you having a data signal to the 74xx595 data in (pin 14) now?
Your "schematic" doesn't show it, and you didn't confirm so far.

It would be good if you start debugging on your side, like attaching a 
scope or logic analyser and measuring some of the key signals (clk, 
data, cs).

Another possibility is that there is a difference in the wiring between 
the working system and the new one (wrong/missing signal connection). 
Please verify.
OP #4926238
Ok let me forward the code for your inspection.

(This code is written for a separate set up on bread board.)
I must apologize to you for bothering you on this.





#include <io.h>
#include <delay.h>
#include <mega32a.h>
/***************************************

Configure Connections

****************************************/

#define HC595_PORT   PORTA
#define HC595_DDR    DDRA

#define HC595_DS_POS PORTA.4      //Data pin (DS) pin location

#define HC595_SH_CP_POS PORTA.5      //Shift Clock (SH_CP) pin location
#define HC595_ST_CP_POS PORTA.6      //Store Clock (ST_CP) pin location

//#define LCD_DATA PORTA.4 // LCD data port
#define en PORTA.2 // enable signal
#define rw PORTA.1 // read/write signal
#define rs PORTA.0 // register select signal


/***************************************
Configure Connections ***ENDS***
****************************************/

//Initialize HC595 System

void HC595Init()
{
   //Make the Data(DS), Shift clock (SH_CP), Store Clock (ST_CP) lines 
output
   //HC595_DDR|=((1<<HC595_SH_CP_POS)|(1<<HC595_ST_CP_POS)|(1<<HC595_DS_POS 
));
   DDRA=0xff;
}


//Low level macros to change data (DS)lines
#define HC595DataHigh() (HC595_PORT|=(1<<HC595_DS_POS))

#define HC595DataLow() (HC595_PORT&=(~(1<<HC595_DS_POS)))

//Sends a clock pulse on SH_CP line
void HC595Pulse()
{
   //Pulse the Shift Clock

   //HC595_PORT|=(1<<HC595_SH_CP_POS);//HIGH
   PORTA.5=1;
   delay_ms(20);
   //HC595_PORT&=(~(1<<HC595_SH_CP_POS));//LOW
   PORTA.5=0;

}

//Sends a clock pulse on ST_CP line
void HC595Latch()
{
   //Pulse the Store Clock

   //HC595_PORT|=(1<<HC595_ST_CP_POS);//HIGH
   PORTA.6=1;
   delay_ms(10);
   PORTA.6=0;
   //HC595_PORT&=(~(1<<HC595_ST_CP_POS));//LOW
   delay_ms(10);
}


/*

Main High level function to write a single byte to
Output shift register 74HC595.

Arguments:
   single byte to write to the 74HC595 IC

Returns:
   NONE

Description:
   The byte is serially transfered to 74HC595
   and then latched. The byte is then available on
   output line Q0 to Q7 of the HC595 IC.

*/
//unsigned int data ;
void HC595Write(unsigned int data)
 {
   //Send each 8 bits serially
    int i=0;
   //Order is MSB first
   for(i=0;i<8;i++)
   {
      //Output the data on DS line according to the
      //Value of MSB
      if(data & 0b10000000)
      {
         //MSB is 1 so output high
         //HC595DataHigh();
         PORTA.4=1;
         delay_ms(1000);
      }
      else
      {
         //MSB is 0 so output high
         //HC595DataLow();
         PORTA.4=0;
         delay_ms(1000);
      }

      HC595Pulse();  //Pulse the Clock line
      delay_ms(1000);
      data=data<<1;  //Now bring next bit at MSB position
      delay_ms(1000);
   }

   //Now all 8 bits have been transferred to shift register
   //Move them to output latch at one
   HC595Latch();
   delay_ms(1000);
  }

/*

Simple Delay function approx 0.5 seconds

*/

void Wait()
{
int i=0;
   for(i=0;i<30;i++)
   {
      delay_ms(10);
   }
}
  int i=0;
 // uint_t data;     //Initialize HC595 system
void main()
{
 DDRB=0xff;
 PORTB=0xff;
 DDRA=0xff;
 PORTA=0xff;

  for(i=0;i<=3;i++) //Startup Led
  {
  PORTB.4=~PORTB.4;
  delay_ms(200);
  }
  PORTB.4=1;

    PORTA.7=0; //pin 13 595
  PORTA.1=0;   //w/r lcd
  PORTA.3=0;   //v0 lcd
  delay_ms(1000);
   HC595Init();
  // LCD init
   HC595Write(0x38);   //Write the data to HC595
         Wait();                 //Wait

  rs=0;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
   rs=0;rw=0;en=0;
   delay_ms(200);
    HC595Write(0x38);   //Write the data to HC595
         Wait();                 //Wait

  rs=0;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
   rs=0;rw=0;en=0;
   delay_ms(20);
    HC595Write(0x38);   //Write the data to HC595
         Wait();                 //Wait

  rs=0;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
   rs=0;rw=0;en=0;
   delay_ms(200);

   HC595Write(0x0f);   //Write the data to HC595
         Wait();                 //Wait

  rs=0;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
   rs=0;rw=0;en=0;
   delay_ms(200);
//  HC595Write(0x0f);   //Write the data to HC595
//         Wait();                 //Wait
//
//  rs=0;rw=0;en=1; // RS and RW as LOW and EN as HIGH
//    delay_ms(10);
//   rs=0;rw=0;en=0;
//   delay_ms(20);



   while(1)
   {
      PORTA.3=0;  // back light on/off
    delay_ms(1000);
         rs=1;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
         HC595Write(0b01010101) ; //Write the data to HC595
         Wait();                 //Wait

   rs=1;rw=0;en=0;
   delay_ms(200);
    rs=1;rw=0;en=1; // RS and RW as LOW and EN as HIGH
    delay_ms(100);
         HC595Write(0x32) ; //Write the data to HC595
         Wait();                 //Wait

   rs=1;rw=0;en=0;
   delay_ms(200);

//     rs=1;rw=0;en=1; // RS and RW as LOW and EN as HIGH
//    delay_ms(1000);
//         HC595Write(0x14) ;   //Write the data to HC595
//         Wait();                 //Wait
//
//   rs=1;rw=0;en=0;
//   delay_ms(20);
//    rs=1;rw=0;en=1; // RS and RW as LOW and EN as HIGH
//    delay_ms(10);
//         HC595Write(0xff) ;   //Write the data to HC595
//         Wait();                 //Wait
//
//   rs=1;rw=0;en=0;
//   delay_ms(20);
     PORTA.3=0;
    delay_ms(1000);


   }


}
#4926267
I think there is a mismatch of the port pins you are using in firmware 
and the actual connections to your hardware. see attached picture.
Also verify the usage of PA3 and PA7 (if I read the "33" correctly in 
the top left corner).
Attached files:
OP #4926462
Yes pin 14 is for data and connected.More to say now I have come to a 
state where the data is reaching to lcd (by connecting led and resistor 
in place of lcd )but nothing is seen in lcd.Please see whats the bug!
#4926790
Please provide an updated and complete schematic as well as the actual 
and latest source code files you are using for this setup.

Btw: source code files could be uploaded as attachments here.

Reply

A question of your own? This thread is over 9 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.