AnsweredAssumed Answered

30F4: TIM16 one-pulse mode not working

Question asked by mike louaillier on Jul 25, 2017

hello can someone look at this code and figure out what's wrong with it. it's supposed to flash an LED for 10 seconds. but it don't. the LED doesn't come on. it will come on if i use a delay loop, but not with TIM16.

 

GPIOA->BSRR |= GPIO_BSRR_BS_4; // turn on LED wired to pin A4

 

TIM16->PSC = 23999; // 24k (PSC + 1)

TIM16->ARR = 21000; // about a 10 second count

TIM16->CNT = 0;

TIM16->EGR = TIM_EGR_UG; // update registers

TIM16->CR1 |= (TIM_CR1_OPM | TIM_CR1_CEN); // Enable and start timer in one pulse mode

 

while(TIM16->CR1 & TIM_CR1_CEN);

GPIOA->BRR |= GPIO_BRR_BR_4; // turn off LED

Outcomes