??? 05/11/09 14:48 Read: times |
#165237 - Yes. You read after the -ve edge. Responding to: ???'s previous message |
I find your functions a little complicated. Surely you are only bit shifting into an unsigned char:
char read_char() { unsigned char c = 0; SCLK = 0; DATA_IO = 1; // make input RESET = 1; for (i = 0; i < 8; i++) { SCLK = 1; c >>= 1; SCLK = 0; if (DATA_IO == 1) c |= 0x80; } RESET = 0; return c; // leaves with SCLK, RESET low } Regarding data integrity. You just write some values to a HT1380 register and then read it back. This should at least confirm your read and write routines match. Trace your read routine. I think it does an extra shift right. David. |