In-appropriate signal from UART

I am using Arduino MEGA 2560 for serial communication.
I am using MATLAB for the coding for the same.

After configuring and downloading the code in the board, I am trying to receive data using Real term software.
The problem is, sometimes I am receiving the correct data and sometimes I am not even if I am sending the same data.

I don’t understand what is the problem. I am attaching screenshot of data i am receiving in both the cases.
Serial Communication details:
baud rate: 115200
datatype: uint16
Board to PC interface: UART to USB converter

Try sending uint8_t data in the range 33 through 126.

If you want help you need to post your program code.
And please use the code button </>so your code looks like thisand is easy to copy to a text editor

…R

thanks.. using uint_8 had helped. It is working fine as of now.

But what if I want to send uint 16 data, what should i do in that case? can you help?

I am not able to post code, as i am flashing code directly from Simulink to the Arduino board.

pisat_swanand: I am not able to post code, as i am flashing code directly from Simulink to the Arduino board.

That does not make sense. Can't you copy and paste the program text?

...R

Robin,

As I am programming arduino through simulink, .c file is not available. Simulink directly generates hex file of the code and flashes it directly onto the board. So I don't have C-code.

Anyway, I could able to break my uint16 data into 2 byte and able to send successfully through serial port.

Thanks for help.

pisat_swanand: As I am programming arduino through simulink, .c file is not available.

Then use something else (like the Arduino IDE) to do your programming.

...R