cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery PIL Fails

marc2
Associate II
Posted on May 05, 2014 at 16:21

Hello everyone,

i've been experimenting with the STM32F4 Discovery Board for quite a time now and i can get the Simulink Test Models to work (Blinking LEDs, USART Echo and so on). When i try to use any of the PIL Models however the trouble begins.

Toolchain: Keil v4

Matlab Version: R2013b

OS: Windows 8.1 x64

Sidenotes: R2014a fails completely, so does automatic path determination for the toolchain in R2013b

- I have installed Matlab in the default directory (C:\Program Files\MATLAB\R2013b)

- I have installed the blocksets in the default directory (C:\Program Files(x86)\STMicroelectronics\STM32F4xx-MAT)

- I have added the folder to my MATLAB Path

- I am aware that for every Simulink Demo Project i have to adjust the path to the system target file and toolchain.

My first problems were similar to the ones reported in this thread:

/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/PIL%20mode%20with%20STM32%20Embedded%20Target%2c%20IAR%2c%20and%20J-LINK&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=196

They are now sorted out.

These are the steps that i have taken from a fresh demo folder:

- set matlab folder to STM32F4xx-MAT\STM32F4xx\STM32F4xxDemos\PIL

- open IIR_Filter_int32.mdl and change simulation mode to ''Processor-in-the-loop''

- adjust system target file and toolchain path

- save IIR_Filter_int32.mdl

- open IIR_Filter_PIL_int32.mdl

- set simulation mode in IIR_FilterInt32 block to PIL

- adjust system target file and toolchain path

- save IIR_Filter_PIL_int32.mdl

- type setpref('STM32F4xx','COMPort','COM4') in matlab console

(yes, COM4 is the right one. this is the only comport i have and it's a usb->rs232 ftdi converter with 3.3V levels)

 

- run iir_startup.m

- Hit the run button

the code generation completes and the compiler succeeds with no errors. strangely no toolchain ever opens up to actually flash the code onto the controller. then a window pops up that lets me choose the usart and pins.

then the following messages appear in matlab:

♯♯♯ Communication parameters is: 115200bds, 8b, 1s, no parity, no hw control

♯♯♯ Preparing to start PIL simulation

after a few seconds an error window pops up giving me a model error ''An installed compiler was not detected'' and the rest of this known default message.

This leaves me completely clueless and since the error message is so common i can't find any useful help on the web.

#pil #stm32f4 #discovery
2 REPLIES 2
marc2
Associate II
Posted on May 07, 2014 at 15:30

okay, i found the solution:

my problem was that i had no compiler installed on windows. so i downloaded the windows sdk from

http://www.microsoft.com/en-us/download/details.aspx?id=8279

 and installed it. note: you need to restart after the installtion, otherwise the required environment variables will not be available (took me a while to figure that out.)

then i typed ''mex -setup'' into the matlab console and used automatic compiler detection to set up my compiler. the path is something like ''c:\program files (x86)\microsoft visual studio 10.0''

the next thing i had to do was manipulate the rtw\stm32f4xx.tmf because apparently the environment variable %MATLAB_WIN_VER% is also not availabe.

i took line 57 ''MAKECMD=%MATLAB%\bin\%MATLAB_WIN_VER%\gmake'' and turned it into ''MAKECMD=%MATLAB%\bin\win64\gmake'' (i'm using 64bit matlab). another solution would be to create the environment variable yourself in the system settings.

bottom line i believe the easiest way to deal with all this is to use a 32bit matlab if you can. it comes with a built-in compiler and saves you from a lot of trouble.

Posted on May 12, 2014 at 17:45

Hi Marc,

1) if you have version with sources provided (.m files and not p-code), you can open ..\script\stm32F4xx_make_rtw_hook.m file.

move :

        %Set environement variable to know windows version 32/64 bits

        winVersion = getenv('MATLAB_WIN_VER');       

        ext = mexext;

        if (isempty(winVersion))

            switch ext

             case 'mexw32'

                    setenv('MATLAB_WIN_VER','win32');

                case 'mexw64'

                    setenv('MATLAB_WIN_VER','win64');

            end

        end

        clear ext winVersion

from case 'before_make'

to case 'entry'

This should solve MATLAB_WIN_VER variable bug.

If you don't have sources, workarround is to modify stm32f4xx.tmf file as you did.

2) For PIL take care that installed repository must be writable because a .h file is crated in

....\pil\stm32F4xxSerialRtiostream repository.

Both will be solved in next release.

Best regards

Pascal