0

as the code shown,

s = serial('COM3','BaudRate',115200, 'Parity', 'odd','DataBits',8,'StopBits',1);
fopen(s);

I add the parity check function in the serial port communication in Matlab. I create the serial port to send data to a FPGA board. In the FPGA board, I write a code to do the XOR operation to the 8 bits data and check whether the result is correct to the parity bit. The problem is if the parity check error exists, how do the FPGA board ask the serial port to retransmit the data? Is there any necessary setting for the FPGA?

Mr.Z
  • 1

1 Answers1

0

Standard UART communication (as used by RS232) does not have internal ACK (acknowledged) and NACK (not acknowledged) capabilities. If you would like the transmitter to resend data, you would have to define the protocol yourself and program it to both transmitter and receiver.

BUT, before you do that, be sure that you truly require retransmit capability because it may be fairly complicated to implement. If you elaborate on your application (what you are trying to do, and what the setup is) I can further consult on the matter. Questions you need to ask yourself:

  1. Physical layer: Why do you receive errors? How often? If you lower the data rate do you receive less errors?
  2. Data handling: Must you receive all the data? Instead of retransmitting, maybe it is better to send the data more than once and have majority vote.
  3. Data correctness: How sure you need to be that the data is valid? Parity check is not that good, as 'two wrongs can make a right'. You may need to implement a higher error detection (+ correctness) mechanism depending on your answer.
  4. Throughput and latency: What are the requirements for channel utilizations?

Also please see: https://electronics.stackexchange.com/questions/29134/handling-of-uart-errors

Community
  • 1
  • 1
Oron Port
  • 467
  • 3
  • 11
  • thx Oron, the purpose of my application is to send an image to the FPGA board. In the Matlab, i first partition an image into R,G,B matrix and then create a serial port to transmit the three matrix data with fwrite instruction. In the FPGA part, I write a code to detect the start bit and then fetch the 8-bit data. 1.Physical layer: Why do you receive errors? How often? If you lower the data rate do you receive less errors? – Mr.Z Jun 19 '16 at 09:01
  • What is your physical connection between computer and board (what cable and connectors, how long is the cable)? How does the receiving end know that you start a new image? – Oron Port Jun 19 '16 at 11:08