2015-04-29 06:33 PM
Hi all,
I want to measure a ~5ms signal at TIM15 Channel 1.Our examples and information I have dont work.Can somebody help me with sample HAL code? Thanks,Osto2015-04-30 03:45 AM
Hi,
you can used CubeMX tool to generating initialization code. There is code example of using timer from my project: TIM_HandleTypeDef Tim6Handle; __TIM6_CLK_ENABLE(); /* TIM6 Time base configuration */ Tim6Handle.Instance = TIM6; Tim6Handle.Init.Prescaler = TIM_ICPSC_DIV1; Tim6Handle.Init.CounterMode = TIM_COUNTERMODE_UP; Tim6Handle.Init.Period = xxx; Tim6Handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&Tim6Handle); /* TIM6 IRQChannel enable */ HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 1, 0); HAL_NVIC_ClearPendingIRQ(TIM6_DAC_IRQn); HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn); __HAL_TIM_SetCounter(&Tim6Handle, 0); __HAL_TIM_CLEAR_IT(&Tim6Handle, TIM_IT_UPDATE); HAL_TIM_Base_Start_IT(&Tim6Handle); Interrupt handling function is called at each period you set void TIM6_IRQHandler(void) { .... }2015-05-01 08:19 AM
Dear Lukas,
This is an example for timebase but I need to measure a signal starting at rising edge and ending at falling edge and I need to measure the width in ~50ns resolution with 24MHz timwe clock.I'm wondering if you have a soulution for my problem.Reagrds,Osto2015-05-03 10:02 PM
Oh I´m sorry :-).
Time measuring based on signal edge I implemented in my app by comparator. Comparator generates interrupt where I measure time. Second solution - comparator output can be connected direct to timer but you have to choose the other.