cancel
Showing results for 
Search instead for 
Did you mean: 

Error: ''Can not find which APB timer TIM1'' with Matlab/Simulink

JMJV
Associate II
Posted on May 02, 2018 at 18:02

I have the next error in the command window of Matlab 2018a''TIMERS_Config function : Can not find which APB timer TIM1 is connected to.Default preference value STM32TIMAPB set to APB1 is used.''

Hello community! first, I know there is a similar question in the community but this one does not solve my problem or my question.

I'm testing the ''Target Suport Package -STM32 Adpater toolbox'' for Matlab 2018a (i'm using this toolbox because is general for any type of STM32 microcontroller, and avoid to install one toolbox for each type of board/microcontroller), and using STM32CUBEMX 4.25.0 with System Workbench for STM32 (eclipse).

So, I created two simple projects: one for testing the Discovery - STM32F407VGTx, using STMCUBE i created a project with one GPIO as input other as output and TIM4 as PWM generation CHI1/CH2/CH3. Then, I proceed to create the Simulink, Matlab model without having any problems with the TIM4 to be assigned to APB1 (I guess is the default clock configured in the ''STM Timer block'' for simulink) by the 

Timer block of the

 ''

Target Suport Package'', because according to the datasheet (STM32F407VGTx) 

http://www.st.com/resource/en/datasheet/DM00037051.pdf

  TIMER4 is assigned to APB1 clock. I also configured the APB1/2 clock frequencies in the STMCUBE project based on the datasheet of the microcontroller. Finally, 

I imported the c files generated and compiled by Matlab into the IDE S

ystem Workbench for STM32 to program the Discovery board. (See Files attached, To compile the program generated by Matlab (INC, SRC) you have to manually add the folder with the INC and SRC files of matlab into the Workbench project go to the tab: /project/properties/C/C++ General/Paths and Symbols/Source Location/Link Folder option). 

0690X0000060AxcQAE.png

Then, in the second project I was trying to test the Nulceo board with the STM32F746ZGTx microcontroller, I also create a simple STMCUBE project using a GPIO as input and other as output, but this time the TIM1 as PWM generator. However, in this type of microcontroller TIM1 is assigned to APB2 according to the

http://www.st.com/content/ccc/resource/technical/document/datasheet/96/ed/61/9b/e0/6c/45/0b/DM00166116.pdf/files/DM00166116.pdf/jcr:content/translations/en.DM00166116.pdf

. I also set the proper 

clock configuration for APB1/2 in the STMCUBE project. Then I proceed to create the Simulink model, the GPIO block works fine without any problem, but when i tried to implement the ''STM Timer block'' i got the next error in the command window of Matlab.

''TIMERS_Config function : Can not find which APB timer TIM1 is connected to. Default preference value STM32TIMAPB set to APB1 is used.''

To try to solve the issue, I have tried different frequencies configurations for APB1/2, I also check the ioc files using Notepad++ to see what is inside of the script and APB2 is assigned, but i could not find any solution still the same error in the command window.

0690X0000060AxbQAE.png

So, my question is How the ''TIMER block'' of Simulink automatically recognize the type of clock assigned (APB1/APB2) according to the CUBE configuration ioc file? 

Is there something missing in my ioc CUBE project that i need to set to assigned TIM1 to APB2 for the Cortex M7?

Is there a kind of button or check to select or enable APB2 for TIM1?

Find Attached the STMCUBE project for the Nucleo-

STM32F746ZGT

 board and the Simulink project.

best

#stm32-mat/target-matlab #simulink #tim
1 REPLY 1
Tomas DRESLER
Senior II

Hello Juan Manuel,

the APBx bus is assigned by STM32 design and cannot be "chosen". Each timer is connected to the specific bus interface and this interface controls the clock, reset, low power activity of the peripheral etc. Further, APB bus distributes the clock to the TIM and because it's operating speed may be limited, the timer core clock has a multiplier by 2, if AHB/APB >= 2.

The first answer: the CubeMx has the information and generates the init code for given TIM with proper clock enable sequence on proper APB bridge registers (RCC peripheral).

If you need to tell Matlab (because it needs to understand what clock the TIM is fed with), you can check block diagram in the datasheet, where assignment to APB's is depicted, or, Reference Manual, where in Table 1. STM32F75xxx and STM32F74xxx register boundary addresses this information is mentioned, too.

Best regards,

Tomas