[MATLAB] Serial communication and data unpacking

1. Configure the serial port in simulnik
insert image description here
2. Take the MCU to send data, and simulink to receive and analyze it as an example

Configure the serial port receiving module, as shown in the figure to receive 5 bytes
insert image description here
3. Use Protocol Decoder to parse the data

First, the microcontroller sends 'A' + four bytes of data
A is the header

test[0]='A';
HAL_UART_Transmit(&huart4,test,1,10);
HAL_UART_Transmit(&huart4,adc1data,2,10);
HAL_UART_Transmit(&huart4,adc2data,2,10);

The simulink settings are as follows:
insert image description here
4. Click to run, and use the display to observe the data

insert image description here

Guess you like

Origin blog.csdn.net/qq_39587650/article/details/123100404