2023-09-12 02:29 PM - edited 2023-09-12 02:34 PM
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 ?
Solved! Go to Solution.
2023-09-12 08:39 PM
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.
2023-09-12 03:09 PM
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
2023-09-12 04:41 PM
Hey @Issamos
According to this pdf p340 ( https://www.embedic.com/uploads/files/20201008/Mastering%20STM32.pdf ), TIM6 doesn't exist on STM32F4 boards:
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 )?
2023-09-12 08:39 PM
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.
2023-09-12 11:23 PM
Hello again @MasterHans
This drive is for all the stm32f4 not specially for the F411 nucleeo. There is other F4 boards that contains TIM6 (the F407 disco for exemple). This macro will be included by CubeMX just when you use a board that support TIM6 not for all boards.
If your question is answered. Close the topic by choosing a best answer.
Best regards.
II
2023-09-13 03:10 AM
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?
2023-09-13 06:23 AM
If you enable them in CubeMX, they will be copied over, but otherwise no, you need to manage them yourself.
There used to be a way to copy all HAL files, even ones that were unused, but it is grayed out in recent versions.
2023-09-13 06:26 AM
You just have to desactivate the generate under root, and the grayed option will be available.
Best regards.
II
2023-09-13 08:58 AM
Good to know. In which case you need to delete the template files on every regeneration, or exclude them from the build.