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.

Code ( (Unknown Language)):

#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.