AnsweredAssumed Answered

Abour uart TX question

Question asked by HAOYUAN CAI on May 10, 2015
Latest reply on May 13, 2015 by David E Seymour

Dear all:

 

      I am confuse recently. When I use uart to send my command and I use PC to receive data(PS: I have used converter to change TTL  voltage to RS232 voltage).Because this part code will be used many times in program(in a loop).the data is correct most of time. but there are still some error data inside . But I have checked  the data in the send buffer of my code is correct, But the data that I  received is error. who can help me ?

 

code:

    fwrite((pointer)Trans_buffer,sizeof(unsigned char),lenth,upload_dev);

   

   

    fflush(upload_dev);

   

    ioctl( upload_dev, IO_IOCTL_SERIAL_WAIT_FOR_TC, NULL );

 

I use these three line code to send data

 

Trans_buffer : the data in this buffer is always correct.

 

example of my data :

 

77 10 80 00 00 77 12 80 00 00 77 14 80 00 00 77 16 80 00 00 77 18 80 00 00 77 1A 80 00 00

77 1C 80 00 00 77 1E 80 00 00 77 20 80 00 00 77 22 80 00 00 77 24 80 00 00 77 26 80 00 00

77 28 80 00 00 77 2A 80 00 00 77 2C 80 00 00 77 2E 80 00 00 77 30 80 00 00 77 80 32 00 00

77 34 80 00 00 77 36 80 00 00 77 38 80 00 00 77 3A 80 00 00 77 3C 80 00 00 77 3E 80 00 00

77 40 80 00 00 77 42 80 00 00 77 44 80 00 00 77 46 80 00 00

 

The red data is error, we can find the second data and the third data exchanged their place.

 

I dont know how to solve this problem.

 

the data send to PC through a voltage converter and Serial port to USB port line    ( PIN:TX RX GND )

Outcomes