cancel
Showing results for 
Search instead for 
Did you mean: 

error: 'TIM_Base_InitTypeDef' has no member named 'AutoReloadPreload'

Siune
Associate II

Hello, I'm using a STM32 F446RETx trying to trigger an ADC conversion on PA0. I use TIM2 Channel 1 using a pwm with no output to trigger the ADC 1 conversion on channel 0. I have exactly one line that trigger an error at compilation (When I comment it, it compile without any error):

../Core/Src/tim.c:48:13: error: 'TIM_Base_InitTypeDef' has no member named 'AutoReloadPreload'

48 | htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

../Core/Src/tim.c:48:34: error: 'TIM_AUTORELOAD_PRELOAD_DISABLE' undeclared (first use in this function)

48 | htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;

I would like to know if I'm using the wrong firmware and if yes, how can I get the IDE to use the correct one.
Or instead how can I configure the AutoReloadPreload register in bare-metal C.

The firmware package I'm using is STM32Cube FW_F4 V1.23.0

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Principal III

Hi,

Try to set TIM_AUTORELOAD_PRELOAD_ENABLE : no error then ?

+

The TIM_AUTORELOAD_PRELOAD_DISABLE value is 0x00000000U , to write it here.

+

I have : F4_V1.27.1 -- try updating your FW , maybe problem solved then.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
AScha.3
Principal III

Hi,

Try to set TIM_AUTORELOAD_PRELOAD_ENABLE : no error then ?

+

The TIM_AUTORELOAD_PRELOAD_DISABLE value is 0x00000000U , to write it here.

+

I have : F4_V1.27.1 -- try updating your FW , maybe problem solved then.

If you feel a post has answered your question, please click "Accept as Solution".

Where did tim.c come from?

If it's part of the CubeF4 github, please indicate where

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Chief III

@Siune wrote:

 

error: 'TIM_Base_InitTypeDef' has no member named 'AutoReloadPreload'


That is wrong.

Use the IDE's 'Go To Definition' feature to go to the definition of TIM_Base_InitTypeDef:

/**
  * @brief  TIM Time base Configuration Structure definition
  */
typedef struct
{
  uint32_t Prescaler;         /*!< Specifies the prescaler value used to divide the TIM clock.
                                   This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */

  uint32_t CounterMode;       /*!< Specifies the counter mode.
                                   This parameter can be a value of @ref TIM_Counter_Mode */

  uint32_t Period;            /*!< Specifies the period value to be loaded into the active
                                   Auto-Reload Register at the next update event.
                                   This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.  */

  uint32_t ClockDivision;     /*!< Specifies the clock division.
                                   This parameter can be a value of @ref TIM_ClockDivision */

  uint32_t RepetitionCounter;  /*!< Specifies the repetition counter value. Each time the RCR downcounter
                                    reaches zero, an update event is generated and counting restarts
                                    from the RCR value (N).
                                    This means in PWM mode that (N+1) corresponds to:
                                        - the number of PWM periods in edge-aligned mode
                                        - the number of half PWM period in center-aligned mode
                                     GP timers: this parameter must be a number between Min_Data = 0x00 and
                                     Max_Data = 0xFF.
                                     Advanced timers: this parameter must be a number between Min_Data = 0x0000 and
                                     Max_Data = 0xFFFF. */

  uint32_t AutoReloadPreload;  /*!< Specifies the auto-reload preload.
                                   This parameter can be a value of @ref TIM_AutoReloadPreload */
} TIM_Base_InitTypeDef;

 You can see that there certainly  is a member of  that called AutoReloadPreload.

Sounds like you have the wrong definition of TIM_Base_InitTypeDef.

So, as @Tesla DeLorean said, where did your definition come from?

I generated that code by using the STM32CubeIDE. But you're write, the uint32_t AutoReloadPreload field is missing in the stm32f4xx_hal_tim.h

I'm surprised to get errors on stuff like that, I also had to add by myself a driver header that was missing after the code generation.

Pavel A.
Evangelist III

The STM32F4 HAL version 1.23.0 is quite old, released before the F4 package was published on github.

The first version on github is 1.24.1 and the AutoReloadPreload field is already there.

https://github.com/STMicroelectronics/STM32CubeF4/blob/b5abca20c9676b04f8d2885a668a9b653ee65705/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h#L71

So please update your library files.

 

Siune
Associate II

I updated my firmware to the last version using CubeMX instead of Cube IDE and now my code compile without errors. Thanks for your help! 🙂