Hi All,, I have a device that clocks out 8-bit data serially on clock and data lines. A data bit is first put on the data pin and then a rising edge appears on the clock pin. Now i want to capture this clocked data into a controller and send it out through its serial port. Can anyone suggest how to go about writing a program for this spoofing ?? Any help would be great. Thankzz && Bye -Rocknmoon
CAn someone throw some quick ideas ?? 1. Tie the clock line to an external interrupt /INT0 or /INT1. 2. Configure the interrupt for edge triggered. 3. In the interrupt read the state of the data line. And accumulate the bits into a byte. When you have received 8 bits, you have a byte. For example:
static unsigned char bit_count = 0; static unsigned char bit_array = 0; void isr_example (void) interrupt ??? { /* accumulate bits MSB first */ /* you may need to change this for your application */ bit_array <<= 1; bit_array |= (READ_BIT_HERE); if (++bit_count >= 8) { /* bit_array is now a completely received byte */ /* do something with it */ bit_count = 0; bit_array = 0; } }
Thanks a lot for the code. Now let us say bit_array = 0x1a; How do i convert this binary value into ASCII so that when i SBUF the converted value and capture it on Hyperterminal window , it appears '1a' (without quotes) ??