This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

data spoofing

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

Parents
  • 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;
      }
    }
    

    Jon

Reply
  • 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;
      }
    }
    

    Jon

Children