Skip to main content
mike louaillier
Associate III
July 25, 2017
Question

30F4: TIM16 one-pulse mode not working

  • July 25, 2017
  • 0 replies
  • 493 views
Posted on July 25, 2017 at 05:08

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

    This topic has been closed for replies.