There is a bottleneck in communication between host and target during External Mode simulation due to which the data update in the Spectrum Analyzer is very slow. This is because the real time processing occurs on the hardware and the data for simulation to be displayed by the Spectrum Analyzer block needs to be transferred back to Simulink via the Serial TTL connection.
During external mode, the baud rate set in "Windows Control Panel -> Device Manager" does not set the baud rate in Simulink. For STM32F4-Discovery board, the baud rate is fixed to 460800 bits/s. If you want to change the baud rate for external mode simulation, you can follow the steps below:
1. Execute the following command to open attributes XML file:
2. At line 45, change the baud rate from 460800 to the required baud rate. For example:
<baudrate value ="921600" visible="false"/>
3. Open RTIO stream file:
4. In the RTIO stream file, at line 99 (inside the rtIOStreamOpen() function), change the baud rate "4 * 115200" with the required baud rate selected in step 2. For example,
With these steps, you can set the external mode simulation with your required baud rate. Please note, for PIL will to work you will also need to change to the baud rate in "codertarget.stm32f4discovery.pil.SerialConnectivityConfig" at line 50.
To open this file,
>> edit codertarget.stm32f4discovery.pil.SerialConnectivityConfig
5. Execute the following commands in MATLAB Command Window after updating the above files:
>> clear pcode;
>> clear classes;
>> rehash path; rehash toolbox; rehash pathreset; rehash toolboxreset;
>> rehash toolboxcache;
Following the above steps will allow you to manually specify the baud rate in Simulink. However, this might not resolve the bottleneck issue but it will provide control over the baud rate.