cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-MAT (Simulink) compiling error with STM32F303RE using TIM

Damien Ratazy
Associate III

I'm trying to compile a simple Simulink model (TIM6 timer that toggles the PA5 pin, configured as GPIO_Output).

I get this error while compiling in IAR :

"Warning[Pe223]: function "__HAL_TIM_SetAutoreload" declared implicitly

However, if I use an another MCU (like the STM32F407VGTx) configured in the same way, I don't get that error!

Here's the source code generated by Simulink :

 * File: TIM_nuc.c
 *
 * Code generated for Simulink model :TIM_nuc.
 *
 * Model version      : 1.33
 * Simulink Coder version    : 8.14 (R2018a) 06-Feb-2018
 * TLC version       : 8.14 (Feb 22 2018)
 * C/C++ source code generated on  : Fri Aug  3 20:24:47 2018
 *
 * Target selection: stm32.tlc
 * Embedded hardware selection: STMicroelectronics->STM32 32-bit Cortex-M
 * Code generation objectives: Unspecified
 * Validation result: Not run
 *
 *
 *
 * ******************************************************************************
 * * attention
 * *
 * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
 * * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
 * * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
 * * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
 * * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
 * * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
 * *
 * ******************************************************************************
 */
 
#include "TIM_nuc.h"
#include "TIM_nuc_private.h"
 
/* Real-time model */
RT_MODEL_TIM_nuc TIM_nuc_M_;
RT_MODEL_TIM_nuc *const TIM_nuc_M = &TIM_nuc_M_;
 
/* Model step function */
void TIM_nuc_step(void)
{
  /* S-Function Block: <Root>/STM32_Config */
}
 
/* Model initialize function */
void TIM_nuc_initialize(void)
{
  /* Registration code */
 
  /* initialize error status */
  rtmSetErrorStatus(TIM_nuc_M, (NULL));
 
  /* user code (Start function Body) */
 
  /*Store TIM6 data information and its handler */
  G_TIM_Data = &TIM6_DataLink;
  G_TIM_Handler = &htim6;
 
  /*Store TIM information */
  TIM6_DataLink.TIM_Prescaler = 0;
  TIM6_DataLink.TIM_APBClock = 72000000;
  TIM6_DataLink.TIM_ARR = 1 - 1;
  TIM6_DataLink.TIM_Clock = 7.2E+7;
  TIM6_DataLink.TIM_Freq = 7.2E+7;
  TIM6_DataLink.CH1_duty = 0.0;
  TIM6_DataLink.CH2_duty = 0.0;
  TIM6_DataLink.CH3_duty = 0.0;
  TIM6_DataLink.CH4_duty = 0.0;
  TIM6_DataLink.CH1_type = UNKNOWN;
  TIM6_DataLink.CH2_type = UNKNOWN;
  TIM6_DataLink.CH3_type = UNKNOWN;
  TIM6_DataLink.CH4_type = UNKNOWN;
 
  /* Interrupt vector initialization */
  TIM6_DataLink.ItUpFcn = NULL;
  TIM6_DataLink.ItTrgFcn = NULL;
  TIM6_DataLink.ItComFcn = NULL;
  TIM6_DataLink.ItBrkFcn = NULL;
  TIM6_DataLink.ItCcFcn = NULL;
 
  /* Auto-reload preload enable */
  SET_BIT((&htim6)->Instance->CR1, TIM_CR1_ARPE);
 
  /*Update register value with blocset value*/
  /*Prescaler*/
  __HAL_TIM_SET_PRESCALER(&htim6,TIM6_DataLink.TIM_Prescaler);
 
  /*Autoreload: ARR */
  __HAL_TIM_SetAutoreload(&htim6, 1 - 1);
 
  /* Time Base start IT */
  HAL_TIM_Base_Start_IT(&htim6);
 
  /* Update interrupt function */
  TIM6_DataLink.ItUpFcn = TIM6_ItUpFcn;
 
  /* Start interrupt for Update event*/
  HAL_TIM_Base_Start_IT(&htim6);
  ;
  ;
}
 
/* File trailer for Real-Time Workshop generated code.
 *
 * [EOF] TIM_nuc.c
 */

Line 87 is posing a problem. 

Can anybody help?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi, @Damien Ratazy​ 

It's because the project didn't include stm32_hal_legacy.h file.

While waiting for new version release, you can fix it for temporary by edit stm32f3xx_hal_def.h file

in Drivers folder of your project (<projectname>\Drivers\STM32F3xx_HAL_Driver\Inc).

Comment or delete line 47 and 49 as below picture.

Best regards,

View solution in original post

2 REPLIES 2

Hi, @Damien Ratazy​ 

It's because the project didn't include stm32_hal_legacy.h file.

While waiting for new version release, you can fix it for temporary by edit stm32f3xx_hal_def.h file

in Drivers folder of your project (<projectname>\Drivers\STM32F3xx_HAL_Driver\Inc).

Comment or delete line 47 and 49 as below picture.

Best regards,

Damien Ratazy
Associate III

Have to try this, thank you