EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / how to interface 74hc595 with ATMEGA 16

how to interface 74hc595 with ATMEGA 16

|

Microcontroller › AVR › how to interface 74hc595 with ATMEGA 16

  • This topic has 3 replies, 3 voices, and was last updated 7 years ago by Hari Prasaath K.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • July 31, 2011 at 8:24 pm #1237
    kamran ullah
    Participant

    hi i am a computer engineering student and i want to interface the ic 74hc595 with my microcontroller(ATMEGA16) someone help me by  giving me code or by making correction in my code
    for input ( parallel to serial conversion ) used ic 74hc165

     

    for input ( serial to parallel conversion ) used ic 74hc595

     

     

     

     
    // ***********************************************************
    // Project:
    // Author:
    // Module description:
    // ***********************************************************
     
    #include <avrio.h>              // Most basic include files
    #include <avrinterrupt.h>       // Add the necessary ones
    #include <avrsignal.h>          // here
    #include<utildelay.h>
     
    int IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8;
    int x1,x2,x3,x4,x5,x6,x7,x8;
     
     
     
     
     
     
    void my_inputcode(void)
    {
     
    // to transfer data enable clock
    //low to high transition is done
    //and clock is disabled
     //DDRD=0x00;
    //PORTD.4=0;// CP Clock
    //PORTD&=~(1<<PD4);
    //PORTD.5=1;// Clear CE Enable 15 cebar
    //PORTD|=(1<<PD5); //works on zero so one
    //PORTC.7=1;// PL Load  1 PLbar
    //PORTC|=(1<<PC7);
    //PORTC.7    = 0;// Load Data
    _delay_ms(10);
    PORTC&=~(1<<PC7);
    _delay_ms(10);
    // Serial Transfer Mode
    PORTC|=(1<<PC7);
    _delay_ms(10);
     
    /enable clock pulses
    //PORTD&=~(1<<PD5);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 1


    // making low to high
    PIND|=(1<<PD4);
    //PORTD|=(1<<PD4);
    _delay_ms(10);
    IN1=(PIND|=(1<<PD6));// Data Pin  01000000
    // Data Pin
    _delay_ms(10);
     // clock zero
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 2


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN2=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 3


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN3=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 4


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN4=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 5


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN5=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 6


    //PORTD.4=1;
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN6=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 7


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
     
    IN7=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    Bit 8


     
    PORTD|=(1<<PD4);
    _delay_ms(10);
    PIN8=(PIND|=(1<<PD6));
    _delay_ms(10);
     
    PORTD&=~(1<<PD4);
    _delay_ms(10);
     
    //


    end


     
     
    // sh/ld parallel load
    PORTC|=(1<<PC7);
     //NIH clock enable
    PORTD|=(1<<PD5);
     
     
    }
     
     
     
     
    void my_outputcode(void)
    {
     
         // output enable active low             OEbar  13
    PORTC|=(1<<PC6);
          // Serial In. DS  Serial Data input     DS     14
    PORTC&=~(1<<PC3);
           // Serial Shift Register Clock.         SH_CP  11
    PORTC&=~(1<<PC2);                       // shift register clock input
     
            // Shift Register Clear.                MRbar  10
                           // master reset active low..
    PORTC|=(1<<PC5);
          // Register Clock.
                           // storage register clock input         ST_CP  12
    PORTC&=~(1<<PC4);
           // 10 master reset (active low)         MRbar  10
    PORTC&=~(1<<PC5);
    _delay_us(50);
    PORTC|=(1<<PC5);
    _delay_us(50);
     
     
    //


    Bit 1


     
                 // 11 shift register clock input        SH_CP  11
    PORTB&=~(1<<PB2);
    _delay_us(10);
     
              // 14 serial data input..               DS     14
    PORTB|=(1<<PB3);
     
    _delay_us(10);
    _delay_ms(2);
     
                 // 11 shift register clock input        SH_CP  11
    PORTB|=(1<<PB2);
    _delay_us(10);
     
     
     
    //


    Bit 2


     
    PORTC&=~(1<<PC2);
    _delay_us(10);
    PORTC&=~(1<<PC3);
     
    _delay_us(10);
     
    PORTC|=(1<<PC2);
     
    _delay_us(10);
     
    //


    Bit 3


     
    PORTC&=~(1<<PC2);
    _delay_us(10);
     
    (PORTC|(1<<PC3));
    _delay_us(10);
     
    PORTC|=(1<<PC2);
    _delay_us(10);
     
    //


    Bit 4


    PORTC&=~(1<<PC2);
    _delay_us(10);
     
    PORTC&=~(1<<PC3);
    _delay_us(10);
    PORTC|=(1<<PC2);
    _delay_us(10);
     
     
    //


    Bit 5


    PORTC&=~(1<<PC2);
    _delay_us(10);
    PORTC|=(1<<PC3);
    _delay_us(10);
     
    PORTC|=(1<<PC2);
    _delay_us(10);
     
    //


    Bit 6


      // First Error Exixst Here
    PORTC&=~(1<<PC2);//PORTC.2=0;
    _delay_us(10);
    PORTC&=~(1<<PC3);//PORTC.3=x6;
    _delay_us(10);
    PORTC|=(1<<PC2);//PORTC.2=1;
    _delay_us(10);
     
    //


    Bit 7


    PORTC&=~(1<<PC2);
    _delay_us(10);
    PORTC|=(1<<PC3);
    _delay_us(10);
    PORTC|=(1<<PC2);
    _delay_us(10);
     
    //


    Bit 8


    PORTC&=~(1<<PC2);
    _delay_us(10);
     
    PORTC&=~(1<<PC3);
    _delay_us(10);
     
    PORTC|=(1<<PC2);
    _delay_us(10);
     
     
     
    // Data Transfer to output.
    PORTC|=(1<<PC4);
     
    PORTC&=~(1<<PC6);
     
    }
     
     
     
     
     
     
    // ***********************************************************
    // Main program
    //
    int main(void)
     
     {
    DDRD&=~(1<<PD6);
    DDRD|=((1<<PD5)|(1<<PD4));
     DDRC=0XFF;
     
    while(1)
    {
      my_inputcode();
               _delay_ms(30);
              // my_outputcode();
    }
     
    }
     
     
     

    its giving me some error and em not able to remove it…

     

    July 28, 2017 at 5:39 pm #14637
    Faroogh
    Participant

    HI !
    If you still interested in 74hc595 please telll me iam working on that using Atmega32A and Atmega8

    July 17, 2018 at 11:58 am #14860
    Faroogh
    Participant

    Can u tell me how to create a library of 74hc595

     

    July 17, 2018 at 5:44 pm #14862
    Hari Prasaath K
    Participant

    Mention the errors your facing, whether during compilation or output error.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • More fun with ws2812 this time XC8 and CLC July 16, 2025
  • Pickit 5 July 16, 2025
  • Pic18f25q10 osccon1 settings swordfish basic July 16, 2025
  • turbo jet fan - feedback appreciated. July 16, 2025
  • I Wanna build a robot July 16, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise