Shift register function
For some reason the code formatter isn't working...
void shiftOut(DigitalOut ds, DigitalOut sh, DigitalOut st, int sodata) {
int i;
// set store low (ready to move to o/p register onchange to high
st = 0;
// byte must be output msb to lsb
for (i=7;i>=0;i--) {
sh = 0;
if (sodata & (1<<i)) {
ds = 1;
} else {
ds = 0;
}
sh = 1;
ds = 0;
}
// move the shifted byte to the output register (appears on output pins)
st = 1;
return;
}
0 comments
You need to log in to post a comment