Init TIM6 with HAL in STM32F7
Hello,
I have a very basic question, I want to enable TIM6 to use it as a tool for generating delays, but I am getting trouble just making TIM6 to work.
Cube MX generated the following code:
static void MX_TIM6_Init(void)
{
/* USER CODE BEGIN TIM6_Init 0 */
/* USER CODE END TIM6_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM6_Init 1 */
/* USER CODE END TIM6_Init 1 */
htim6.Instance = TIM6;
htim6.Init.Prescaler = 100;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 0;
htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM6_Init 2 */
/* USER CODE END TIM6_Init 2 */
}
In main() I have the following code:
__HAL_RCC_TIM6_CLK_ENABLE();
__HAL_TIM_ENABLE(&htim6);
__HAL_TIM_SET_COUNTER(&htim6, 0);
while(__HAL_TIM_GetCounter(&htim6) <= 100);
The program never leaves the while() so I assume that the TIMER is not working.
The micro it wokinrg at maximum speed 216Mhz.
What is the problem????
Thanks!
