Skip to main content
Graduate II
September 12, 2023
Solved

Why __HAL_RCC_TIM6_CLK_ENABLE() macro is used but not defined?

  • September 12, 2023
  • 2 replies
  • 3444 views

I am using a STM32F411RE board, and cubeIDE.

__HAL_RCC_TIM6_CLK_ENABLE(); macro from Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_timebase_tim_template.c is called in the function HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority), however it isn't defined anywhere in the Github project of STM32CubeF4 ( https://github.com/STMicroelectronics/STM32CubeF4 ).

In the driver of STM32F0 serie, in stm32f0xx_hal_rcc_ex.h is, it is defined this way:
```c
#define RCC_APB1ENR_TIM6EN_Pos (4U)
#define RCC_APB1ENR_TIM6EN_Msk (0x1U << RCC_APB1ENR_TIM6EN_Pos) /*!< 0x00000010 */
#define RCC_APB1ENR_TIM6EN RCC_APB1ENR_TIM6EN_Msk /*!< Timer 6 clock enable */
#define __HAL_RCC_TIM6_CLK_ENABLE() do { \
__IO uint32_t tmpreg; \
SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN); \
/* Delay after an RCC peripheral clock enabling */ \
tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN); \
UNUSED(tmpreg); \
```

So do we have to create this macro in stm32f4xx_hal.h which is imported at the beginning of stm32f4xx_hal_timebase_tim_template.c ?

    This topic has been closed for replies.
    Best answer by TDK

    It exists on some STM32F4 chips, just not yours.

    stm32f4xx_hal_timebase_tim_template.c is a template file. It is meant to be modified to suite your hardware. If you aren't using a timer as a systick, you can delete it.

    Unclear how you generated your files, but if you do so via CubeMX, the template file will not be included and the project will build successfully.

    2 replies

    Graduate II
    September 12, 2023

    Hello @MasterHans 

    Also, in the STM32CubeF4 the __HAL_RCC_TIM6_CLK_ENABLE() is defined exactly the same way as in the stm32CubeF0. In the stm32f4xx_hal_rcc_ex.h you can find this:

    #define __HAL_RCC_TIM6_CLK_ENABLE() do { \

                                          __IO uint32_t tmpreg = 0x00U; \

                                          SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\

                                          /* Delay after an RCC peripheral clock enabling */ \

                                          tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM6EN);\

                                          UNUSED(tmpreg); \

                                          } while(0U)

    Best regards.

    II

    Graduate II
    September 12, 2023

    Hey @Issamos 

    According to this pdf p340 ( https://www.embedic.com/uploads/files/20201008/Mastering%20STM32.pdf ), TIM6 doesn't exist on STM32F4 boards:

    MasterHans_1-1694507145840.png

     

    So this macro __HAL_RCC_TIM6_CLK_ENABLE() shouldn't have been called in a STM32F4xx driver isn't it?

    Should I create an issue on the Github STM32CubeF4 ( https://github.com/STMicroelectronics/STM32CubeF4 )?

     

     

    TDKAnswer
    Super User
    September 13, 2023

    It exists on some STM32F4 chips, just not yours.

    stm32f4xx_hal_timebase_tim_template.c is a template file. It is meant to be modified to suite your hardware. If you aren't using a timer as a systick, you can delete it.

    Unclear how you generated your files, but if you do so via CubeMX, the template file will not be included and the project will build successfully.

    Graduate II
    September 13, 2023

    Thanks guys.

    @TDK I created a new project in CubeIDE from ST32F411RE board. Then since I have an NFC01A1 module connected to the STM32, I added the driver BSP from the zip folder ( https://www.st.com/en/embedded-software/x-cube-nfc1.html ) inside the Drivers folder of my project.

    BSP is using the i2c module, so I changed stm32f4xx_hal_conf.h to enable the i2c module. However, the generated driver of STM32F4xx_HAL_Driver doesn't have the i2c module. So I took the driver STM32F4xx_HAL_Driver folder from the Github of STM32CubeF4 and put it instead of the generated driver.

    Is there a way to get all the drivers of modules working directly from CubeMX?