Sending long chunks of bits via RS232

Discussion in 'Wireless & RF Design' started by Peter Pan, Feb 1, 2010.

  1. Peter Pan

    Thread Starter Senior Member

    Mar 24, 2005
    122
    0
    Hello,

    As I know from books RS232 protocol assumes a frame's structure like this:

    start bit - 8 data bits - stop bit

    where there are only 8 data bits in a frame.

    However, in my project I need to send 64 bit data chunks and hence my question is - whether it's actually possible to send it in a single frame or I have to invent something else in order to accomplish it?

    Thank you.
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    The RS-232 protocol got established for 8 bit words - http://en.wikipedia.org/wiki/RS-232

    You can always use a more capable and faster serial protocol, like USB instead.

    You can always use the receiving device (sounds like a computer) to shift the 8 bit words into a register 8 times to assemble each 64 bit word.
     
  3. Peter Pan

    Thread Starter Senior Member

    Mar 24, 2005
    122
    0
    Unfortunately, my Spartan 3E 1600 Microblaze Development board does not allow USB communication for data transfer. USB port on this board can be used for programming FPGA only.

    Okay. I just wonder - would a FIFO of size 64XN be a right choice in order to receive N words of 64 bit length each in this case?
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    All UARTs have a fifo implemented. In microcontrollers this FIFO may only be 1 byte.
     
  5. Peter Pan

    Thread Starter Senior Member

    Mar 24, 2005
    122
    0
    Okay. I am working with FPGA so my approach perhaps will be like this (critical suggestions are appreciated!):

    I'll implement a serial-to-parallel shift register whose serial input is connected to Tx of RS232 (when data are sent from PC to my FPGA board) so that parallel output of the shift register will be connected to input of my FIFO whose size allows reception of N words of 64-bit length each and N is just some big number (about 1024 may be).

    Although UART has its own FIFO, its size maybe not large enough for my project and also my approach allows to rearrange the data sent into 64-bit word format which is convenient for processing in my project.
     
  6. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    RS232 is an an asynchronous character based protocol. It does not support the concept of frames, only characters. If you want to send 64 bits of data you just send 8 characters.

    What you are talking about is synchronous data transmission where data is sent as a series of frames with flags between frames but no start and stop bits in the actual data stream.

    I have had no dealing with the kit you are using so can't offer specific advise but many systems do have on-board synchronous comms support. The other option is to add a stand-alone USRT or USART (but not UART which only does asynch comms).
     
  7. Peter Pan

    Thread Starter Senior Member

    Mar 24, 2005
    122
    0
    Okay. So, is sending this: start bit - 64 bits - stop bit via RS232 valid?
     
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Not if your device is comunication with any standard RS232 device like say a PC or microcontroller. In such a case you have to send it as 8 bytes.
     
  9. Papabravo

    Expert

    Feb 24, 2006
    10,179
    1,800
    In theory there is no problem doing this as long as both the receiver and the transmitter both agree on the framing and the baudrate. Your problem in asyncronous communications will be different clock frequencies at the receiver and transmitter. In a 10-bit frame (1 Start, 8 Data, 1 Stop) the transmit and receive clocks must be within +/- 2% for reliable data recovery. This is because the sample point which starts out in the middle of a bit cell will drift into either the next bit or the previous bit depending on weather your receive clock is faster or slower than the transmit clock.

    In a 66 bit frame, your maximum baudrate will be limited by the clock accuracy on each end. You should be careful what you wish for, because you might end up with Pandora's box.
     
  10. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    Take a look at the HDLC protocol, it is the link layer protocol used by many high level communications protocols http://en.wikipedia.org/wiki/High-Level_Data_Link_Control is one site that describes it but there are many more if you search.

    As Papabravo said the problem with asynchronous communications is clock accuracy. Asynch protocols such as RS232 use free running clocks at each end to sample the data. Synchronisation between the send and receive clocks is re-established each time the receive clock gets a start bit, which in RS232 is at the start of each character so the clocks re-synchronise after every 10 bits. This means that the clock accuracy between send and receive only needs to be +/- 5% (best case) or 2% to allow for some sampling offset.

    If you try to send 64 data bytes without re-synchronising the clocks your clock correlation will need to be better than 0.7%.

    You could do it that way but synchronous transmission would be much more reliable, very much more efficient and you would not be running a non-standard protocol that no-one else supports.
     
Loading...