cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F29I + MATLAB

smrtkai
Senior
Posted on July 03, 2015 at 16:14

Hi,

I am trying to program the discovery board using MATLAB+Simulink. Unfortunately the examples are not working on my board.

I followed the simple example on Mathworks. I changed the pin to PG13, because on my board the LED is connected to this port.

http://de.mathworks.com/help/supportpkg/stmicroelectronicsstm32f4discovery/examples/getting-started-with-embedded-coder-support-package-for-stmicroelectronics-stm32f4-discovery-board.html

Everything compiles without an error. The program is downloaded to the board, but nothing happens.

This is my board:

http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF259090

Can anyone help me to get it working?

Best Regards,

Kai
12 REPLIES 12
smrtkai
Senior
Posted on July 06, 2015 at 12:00

I also followed this video, but it is not working:

https://www.youtube.com/watch?v=U8jT2lqU0bU

Simulink does not recognize the ''compiler'', which should be STM32CubeMX. The problem is also discussed at mathworks.

https://www.mathworks.com/matlabcentral/answers/222773-unable-to-generate-code-for-

stm32#comment_295551

The difference between the setup in the video and my setup is the MATLAB version. Is STM32-MAT/TARGET compatible with MATLAB R.2015a?
Amel NASRI
ST Employee
Posted on July 06, 2015 at 13:28

Hello smrtkai,

Can you debug your application? Is it stopping execution at some level?

We need t understand how exactly it is not working.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

smrtkai
Senior
Posted on July 06, 2015 at 13:39

Thanks for the quick response. Sorry, I forgot to post the error message. Matlab/Simulink is unable to start STM32CubeMX, when I try to build the model. The only difference between the setup in the video and my setup is the Matlab version. I have Matlab R2015a installed.

Matlab returns the following error:

An installed compiler was not detected. Certain simulation modes, as well as host-based coder builds require that a compiler be installed. Please install one of the supported compilers for this release as listed at:

http://www.mathworks.com/support/compilers/R2015a/win64.html

MATLAB must be restarted after the compiler is installed.

Component: Simulink | Category: Model error

I followed another approach, but that is not related to your STM32-MAT/TARGET. Its with the hardware support package downloadable directly within Matlab. With this approach the compiler works fine but nothing is executed on the device itself.
smrtkai
Senior
Posted on July 06, 2015 at 15:06

I figured out, that the error occurs in ''setup_for_lcc''. LCC stands Local C Compiler. But

there is no LCC shipped with Matlab 64bit. Changing line 67 in setup_for_lcc.m to ''args.mexOpts = rtwprivate('getMexCompilerInfo');'' fixed the problem.

The question is: Why is ''setup_for_lcc'' invoked, when there are alternate and more advanced compilers installed and setup?

>> cc = mex.getCompilerConfigurations;

>> cc(1)

ans =

  CompilerConfiguration with properties:

             Name: 'Microsoft Visual C++ 2013 Professional'

     Manufacturer: 'Microsoft'

         Language: 'C++'

          Version: '12.0'

         Location: 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\'

        ShortName: 'MSVCPP120'

         Priority: 'B'

          Details: [1x1 mex.CompilerConfigurationDetails]

       LinkerName: 'link'

    LinkerVersion: ''

           MexOpt: 'C:\Users\Kai\AppData\Roaming\MathWorks\MATLAB\R2015a\mex_C++_win64.xml'

>> cc(2)

ans =

  CompilerConfiguration with properties:

             Name: 'Microsoft Visual C++ 2013 Professional (C)'

     Manufacturer: 'Microsoft'

         Language: 'C'

          Version: '12.0'

         Location: 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\'

        ShortName: 'MSVC120'

         Priority: 'B'

          Details: [1x1 mex.CompilerConfigurationDetails]

       LinkerName: 'link'

    LinkerVersion: ''

           MexOpt: 'C:\Users\xxx\AppData\Roaming\MathWorks\MATLAB\R2015a\mex_C_win64.xml'
Amel NASRI
ST Employee
Posted on July 06, 2015 at 15:53

And if you follow the instructions provided in the error message, what do you get?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

smrtkai
Senior
Posted on July 07, 2015 at 09:46

I followed the instructions by installing ''Windows SDK 7.1'' and ''Visual Studio 2013 Professional''. As you can see in my previous post, the compilers are configured correctly. I configured the compilers using ''mex -setup''.

Posted on July 15, 2015 at 14:21

Hello,

this pb will be resolved for next STM32-MAT/Target version.

Please, edit \STM32\rtw\stm32.tmf

Line 68

Please add ''COMPILER_TOOL_CHAIN = default''

in order to have:

SYS_TARGET_FILE = stm32.tlc

COMPILER_TOOL_CHAIN = default

MAKEFILE_FILESEP = /

Save file.

It should be ok.

Best regards

Pascal

smrtkai
Senior
Posted on November 17, 2015 at 15:43

Finally, I have gotten the Matlab licenses to program STM32 microcontrollers with Matlab.

I want to report another issue with the Matlab target. If you create the STM32CubeMX project from within Matlab, you cannot generate the code. You have to create the STM32CubeMX -project on its own and select it within Matlab. And you need to generate the code at least once from STM32CubeMX. If not Matlab will generate an output file (*.out) with the content ''Dumy File'' [no typo ;-)].

I would really appreciate an official guide on how to use the Matlab target. Maybe there exists one, that I haven't found yet.
smrtkai
Senior
Posted on November 17, 2015 at 17:52

I have encountered another problem. When using MATLAB R2015a it is possible to generate code through STM32CubeMX but there is no Matlab-generated code within the Keil-project.

When I click on ''Build Model'' in MATLAB, STM32CubeMX asks for a project name and location. After setting the configuration the code is generated, but it is simply the code generated from STM32CubeMX. Matlab-Code is completely missing. Although I did set the configuration in advance, Matlab asks for the project configuration. :(

Is anyone using Matlab to generate code for STM32 at all? Seems like there are a lot of issues to be solved, to get it working properly.

Thanks for your help in advance.