I used one pulse mode:
Code: Select all
// Initialize Timer 6
// - enable TIM6 clock
// - set prescaler for 1 µs resolution
// - one pulse mode
// - force update
#if STM32_CORE_VERSION < 0x01070000
RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;
TIM6->PSC = (uint32_t)(getTimerClkFreq(TIM6) / (1000000)) - 1;
TIM6->CR1 |= TIM_CR1_OPM;
// Clear the update flag
TIM6->SR = ~TIM_SR_UIF;
// Enable interrupt on update event
TIM6->DIER |= TIM_DIER_UIE;
// Enable TIM6 IRQ handler
HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM6_IRQn);
#else
// Enable TIM6 IRQ handler
readTimer->setInterruptPriority(0, 0);
readTimer->setPreloadEnable(true);
readTimer->attachInterrupt(readIRQHandler);
#endif
Code: Select all
#if STM32_CORE_VERSION < 0x01070000
TIM6->ARR = 127 * worker.period - 1;
TIM6->CR1 |= TIM_CR1_CEN;
#else
readTimer->setOverflow(127 * worker.period, MICROSEC_FORMAT);
readTimer->resume();
#endif
Code: Select all
#if STM32_CORE_VERSION < 0x01070000
extern "C" void TIM6_IRQHandler() {
// One pulse
TIM6->SR = ~TIM_SR_UIF;
lep_output();
}
#else
void readIRQHandler(void) {
readTimer->pause();
lep_output();
}
#endif
Is there a way to achieve this with current HardwareTimer an if no, is it possible to add it in a future release?