cancel
Showing results for 
Search instead for 
Did you mean: 

reset timer count value

Aes.1
Associate

i wrote a program and i want to turn on the led after passing a 500 and 750 , 1000ms.

i use out put compare and use active on mach timer mode.

but it only work one time , i realize that i should reset my timer and count value but i don't know how?

please solve my problem.

thanks in advance.

 while (1)

 {

HAL_TIM_OC_Start(&htim3,TIM_CHANNEL_1);

HAL_TIM_OC_Start(&htim3,TIM_CHANNEL_2);

HAL_TIM_OC_Start(&htim3,TIM_CHANNEL_4);

HAL_Delay(2000);

HAL_TIM_OC_Stop(&htim3,TIM_CHANNEL_1);

HAL_TIM_OC_Stop(&htim3,TIM_CHANNEL_2);

HAL_TIM_OC_Stop(&htim3,TIM_CHANNEL_4);

sConfigOC.OCMode = TIM_OCMODE_ACTIVE;

 sConfigOC.Pulse = 500;

 sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;

 sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

 if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)

 {

  Error_Handler();

 }

 sConfigOC.Pulse = 750;

 if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)

 {

  Error_Handler();

 }

 sConfigOC.Pulse = 1000;

 if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)

 {

  Error_Handler();

 }

1 REPLY 1
dbgarasiya
Senior II

TIMx->CNT = 0;