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
You are here: Home / Topics / interfacing two 74HC374 on single port of 8051

interfacing two 74HC374 on single port of 8051

|

Microcontroller › 8051 › interfacing two 74HC374 on single port of 8051

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 4 months ago by Rajdeep singh.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 17, 2013 at 4:36 pm #4805
    Rajdeep singh
    Participant

    Hello sir

                  i am trying to interface two 74hc374 with 8051 on single port but getting problem, here is my condition and my program also,

      Q:  I have 16 switches as a input 1st 8 switch used for 1st 74hc374 and next 8 switch used for 2nd 74hc374,at the output of 74HC374 we have LED’s. if we will press switch one first output pin of 74hc374 is high (i.e LED1 high) same upto 16th switch.

     

    #include<reg52.h>
    sbit row1 = P1^0;
    sbit row2 = P1^1;
    sbit row3 = P1^2;
    sbit row4 = P1^3;

    sbit col1 = P1^4;
    sbit col2 = P1^5;
    sbit col3 = P1^6;
    sbit col4 = P1^7;

    sbit LED0 = P2^0;
    sbit LED1 = P2^1;
    sbit LED2 = P2^2;
    sbit LED3 = P2^3;
    sbit LED4 = P2^4;
    sbit LED5 = P2^5;
    sbit LED6 = P2^6;
    sbit LED7 = P2^7;

    sbit clock1=P3^0;
    sbit clock2=P3^1;

     void check_col1()
    {
      clock1=clock2=0;
     row1=row2=row3=row4=1;
     row1=0;
     if(col1==0)
     {
        clock1 = 1;
        LED0 = 1;
        clock1 = 0;
     }
        row1=1;
        row2=0;
     if(col1==0)
     {
       clock1=1;
       LED1=1;
       clock1 = 0;
     }
     row2=1;
     row3=0;
     if(col1==0)
     {
      clock1=1;
      LED2=1;
      clock1 = 0;
     }
     row3=1;
     row4=0;
     if(col1==0 )
     {
       clock1=1;
       LED3=1;
       clock1 = 0;
     }
      row4=1;
    }

    void check_col2()
    {
      clock1=clock2=0;
      row1=row2=row3=row4=1;
      row1=0;
      if(col2==0)
      {
        clock1=1;
        LED4=1;
        clock1 = 0;
      }
      row1=1;
      row2=0;
      if(col2==0)
      {
        clock1 = 1;
        LED5=1;
        clock1 = 0;
     }
      row2=1;
      row3=0;
      if(col2==0)
      {
        clock1=1;
        LED6=1;
        clock1 = 0;
      }
      row3=1;
      row4=0;
      if(col2==0)
      {
       clock1=1;
       LED7=1;
       clock1 = 0;
      }
       row4=1;
    }

     void check_col3()
    {
     clock1=clock2=0;
     row1=row2=row3=row4=1;
     row1=0;
     if(col3==0 )
     {
       clock2=1;
       LED0=1;
       clock2 = 0;
     }
        row1=1;
        row2=0;
     if(col3==0)
     {
       clock2 = 1;
       LED1=1;
       clock2 = 0;
       }
     row2=1;
     row3=0;
     if(col3==0)
     {
       clock2=1;
       LED2=1;
       clock2 = 0;
     }
     row3=1;
     row4=0;
     if(col3==0)
     {
       clock2 = 1;
       LED3=1;
       clock2 = 0;
     }
      row4=1;
    }

    void check_col4()
    {
       clock1=clock2=0;
      row1=row2=row3=row4=1;
      row1=0;
      if(col4==0)
      {
       clock2=1;
       LED4=1;
       clock2 = 0;
      }
      row1=1;
      row2=0;
      if(col4==0)
      {    
       clock2 = 1;
       LED5=1;
       clock2 = 0;
      }
      row2=1;
      row3=0;
      if(col4==0 )
      {
        clock2=1;
        LED6=1;
       clock2 = 0;
      }
      row3=1;
      row4=0;
      if(col4==0 )
      {
        clock2=1;
        LED7=1;
       clock2 = 0;
      }
       row4=1;
    }

    void main()
    {
     
     LED0=LED1=LED2=LED3=LED4=LED5=LED6=LED7=0;
     clock1=clock2=0;
     while(1)
     {

      col1=col2=col3=col4=1;  //input port
      row1=row2=row3=row4=0;
      if(col1==0)
     
       {
         check_col1 ();
                   
       }
       if(col2==0)
       {

       check_col2();
        
      }      
       if(col3==0)
       {
       
         check_col3();
        
       }
       if(col4==0)
       {
        
        check_col4();
        
       }
     }
    }

     

     

    main problem is 1st 8 switch are working properly but when pressing 9th switch all the LEDs are high together of 2nd 74HC374.

     

    April 18, 2013 at 12:10 pm #9513
    Chester Anderson
    Participant

    can you please post a more clear picture of the circuit??

    April 20, 2013 at 6:11 am #9538
    Rajdeep singh
    Participant

    tobin creg : i did not declare because all the led’s are using same port,LED0=LED1=LED2=LED3=LED4=LED5=LED6=LED7=0 are using  P2^0 = LED0,P2^1 = LED1,P2^2 = LED2,P2^3 = LED3,P2^4 = LED4,P2^5 = LED5,P2^6 = LED6,P2^7 = LED7, its not output LEDsits only port name

    April 20, 2013 at 6:43 am #9540
    Rajdeep singh
    Participant

    tobin creg : i did not define because it is connected on single port which has only 8 pins,LEDs are the name of P2.0 to P2.7 it is not the name of output of 74HC374

    April 20, 2013 at 7:01 am #9541
    Rajdeep singh
    Participant

    Chester Anderson wysiwyg_imageupload:8234:: here is the clear picture

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

RSS Recent Posts

  • Seeking Help to compile code August 17, 2022
  • Nokia 5110 HW in Oshonsoft August 17, 2022
  • Digital Display Information August 17, 2022
  • 2nd pcb design program? August 17, 2022
  • Door exit button August 17, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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