Hello , I am using Atmega128 and 8 shift registers 6D595 the ser_out of each register is connected to the next shift register's ser_in so they form a chain. There is no issue with the hardware it has been tested. I am using 4 16 bit variables to send data to shift registers. the problem that i am facing is that only once i am able to latch out the values only once .. For example if i send 4 variables as 0x0011,0xFF00,0x3c1d,0x1100 (they can be anything ) then i get the output on my 8 segment panel. but i am only able to update my registers only once . if i try to update them in a loop the program only shows the first value that i had sent to the shift register function
here is what i am doing in my shift out register
<code>
void shift_out(uint16_t data[4])
make latch pin HIGH
for(int x=0;x<3;x++)
{
for(int i=0;i<16;i++)
{
set data pin according to data[x]
give a low pulse to clock pin then make it high
}
}
give a low pulse to latch pin then make it high
</code>
if i call this function once it works perfectly fine
but if i call it again with different values nothing happens
please help me i am not sure what else information i am supposed to share.. but i am willing to share anything.. Thanks in advance!!
I found out that the program doesnt return from my function but keeps on performing this function even if it is not in a loop
void shift_out_data2(uint16_t data1,uint16_t data2,uint16_t data3,uint16_t data4) { for(int i=0;i<16;i++) { if(data1 & (1<<(i))) PORTC |= (1<<(3)); // data pin else PORTC &= 0b11110111; // data pin PORTC |= (1<<(4)); //clock pin _delay_us(10); PORTC &= 0b11101111; // clock pin } for(int i=0;i<16;i++) //same loop as above but for next data { if(data2 & (1<<(i))) PORTC |= (1<<(3)); else PORTC &= 0b11110111; PORTC |= (1<<(4)); _delay_us(10); PORTC &= 0b11101111; } for(int i=0;i<16;i++) { if(data3 & (1<<(i))) PORTC |= (1<<(3)); else PORTC &= 0b11110111; PORTC |= (1<<(4)); _delay_us(10); PORTC &= 0b11101111; } for(int i=0;i<16;i++) { if(data4 & (1<<(i))) PORTC |= (1<<(3)); else PORTC &= 0b11110111; PORTC |= (1<<(4)); _delay_us(10); PORTC &= 0b11101111; } PORTC |= 0b00000100; // latch pin PORTC &= 0b11111011; //latch pin }