How to change output frequency of timer during run time
I am using stm32L073Rz
I am using Tim2 channel 3 to generate different frequencies
As per an example ,i configure timer 2 channel 3 in TIM_OCMODE_TOGGLE mode
when i generate code using cubemx i get the desired frequency using below code snippet
but i want to change the frequency during runtime
so i use same code ,just change sConfigOC.Pulse value in main() but than output stops coming
so how to change output frequency at my will in the program,can i write some register directly ?
sConfigOC.Pulse = 16000;
if (HAL_TIM_OC_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
HAL_Delay(500);
if(HAL_TIM_OC_Start_IT(&htim2, TIM_CHANNEL_3) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}