2018-02-15 01:59 AM
We are using stm32f051r4t6 IC for a new project and IDE used is Keil V5 . We are using Timer_3 running at 8MHz internal clock to generate a timer delay but , by varying PSC and ARR registers we always obtain nearly 4us . How could we vary the timer overflow time . Any help would be greatly appreciated .
void Timer3_Init()
{RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
TIM3->ARR = 0xFFFF; TIM3->PSC = 0x0000; TIM3->EGR |= TIM_EGR_UG;TIM3->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN;
TIM3->DIER |= TIM_DIER_UIE;
NVIC_EnableIRQ(TIM3_IRQn);
}void TIM3_IRQHandler(void)
{ if((TIM3->SR & TIM_SR_UIF)) { TIM3->SR &=~ TIM_SR_UIF; TIM3->EGR |= TIM_EGR_UG;// toggle gpio pin
}}
#stm32f0-timer #stm32f0 #stm32f0-counter2018-02-15 04:07 AM
Remove this line from the IRQHandler:
TIM3->EGR |= TIM_EGR_UG;
This line means 'simulate update', i.e. it fires the interrupt immediately again.
JW