Associate III
March 31, 2019
Question
Problem with duty cycle measurement
- March 31, 2019
- 1 reply
- 760 views
Hello everybody,
I wanted to measure the duty cycle (tone) of a PWM signal with input capture mode. Unfortunately, it works only almost up to 65% of the duty cycle(Ton). otherwise will
the T_off measured instead of Ton. does anyone have an idea what can i do to solve this
problem?
the timer has a clock frequency of 1 MHz.
#TIMER #PWM
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_1);
HAL_TIM_Base_Start(&htim5);
HAL_TIM_IC_Start_IT(&htim5, TIM_CHANNEL_1);
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(htim);
if(htim==&htim5){
// HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET);
capture= HAL_TIM_ReadCapturedValue(&htim5,TIM_CHANNEL_1);
__HAL_TIM_SetCounter(&htim5,0);
}
}