I am trying to write a function in C that will shift out the individual bits of a byte based on a clock signal. So far I have come up with this...
void ShiftOutByte (char Data)
{
int Mask = 1;
int Bit = 0;
while(Bit < 8)
{
while(ClkPin == LOW);
DataPin = Data && Mask;
Mask = Mask * 2;
Bit++;
}
}
where DataPin represents the port pin that I want to shift data out on and ClkPin is the clock port pin.
I want the device to shift out 8 bits, starting on the LSB of the byte. For some reason my output pin stays high all the time. I am certain that the port pins are configured properly so it is purely a logical issue.