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
  • >What about the 8051 UART in Mode 0?

    OK. This would work for seding out the data.
    I am actually for some sample code that can capture the bit oriented data from the data pin on each clock edge, make bytes out of this bit stream and send it out on the UART. CAn someone throw some quick ideas ??

    Thanks in advance.

    Rocknmoon

Reply
  • >What about the 8051 UART in Mode 0?

    OK. This would work for seding out the data.
    I am actually for some sample code that can capture the bit oriented data from the data pin on each clock edge, make bytes out of this bit stream and send it out on the UART. CAn someone throw some quick ideas ??

    Thanks in advance.

    Rocknmoon

Children
  • 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

  • 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) ??