I am trying to write a function in C that will shift 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 that I want to transfer data, and ClkPin is the output of the clock port.
I want the device to shift 8 bits, starting with the low byte of the byte. For some reason, my output is constantly high. I am sure that the port pins are configured correctly, so this is a logical problem.
source
share