sebastiaan goossens

STM32-MAT Simulink problems

Discussion created by sebastiaan goossens on Mar 16, 2017
Latest reply on Mar 20, 2017 by reynaud.pascal

I am trying to get the STM32-MAT package to work with Simulink to do some test on a stm32f4discovery board and I am running into multiple issues.


1. A simple Simulink setup for a normal build:


When building this simple model, the above error occurs.


2. Trying out the PIL filter demo from the STM32demos folder of the STM32-MAT package.

I select the correct uart settings, the processor and speed. For the uart I use usart2 at PA3 and PA2. The toolchain I use is SW4STM32.


When the configuration for STM32CubeMX opens, the uart port has the following configuration error:

The correct keyword according to the program should be WORDLENTH_8B, not UART_WORDLENGTH_8B. This has to be fixed manually every time and prevents the project generation from working when the call to CubeMX is hidden.


3. If the issue above is fixed manually and the project is generated and opened with SW4STM32, the compilation errors out with missing files. This is due to the include paths being messed up with the quotes:

These can be fixed manually but then it errors out because there is an extra file which has no rule for make:



This file seems to be included by accident and the include itself is some hardcoded path to a username (not mine). The file and include can be deleted to make the compilation finally succeed.


4. If the compiled image then is uploaded to the target (stm32f4discovery) and simulink is continued, it times out on the uart communication. I can verify something is sent from the windows machine, but for some reason nothing is done with the command. I have also verified in the debugger that the correct uart device is receiving this command.


For every simulation, the paths to stm32-mat and STM32CubeMX have been set up correctly.

I have the following versions of programs:

Matlab r2016b (with all the required toolboxes)

STM32CubeMX 4.20.0 with STM32F4 package 1.15.0

SW4STM32 v1.14.0



Does anyone have any idea on how to get the normal compiling working and how to get the demo working?

Any help would be highly appreciated!