Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years ago.
Unable to get timer interrupt Nucleo F103RB
Hi , I have used the following code for f103rb but I don't seem to be getting an interrupt. My counter is working fine as verified using the st link utility.
My code is
#include "stm32f10x.h" #include "system_stm32f10x.h" #include "core_cm3.h" void TIM3_IRQHandler(); int main(void) { SystemInit(); RCC->APB1ENR |=0x2; // Timer 3 clk enable RCC->APB2ENR |= 0x804; // __PortA_CLK_Enable() GPIOA->CRL = (0x00003333); // Port A bits 0 to 3 are in output mode , max speed 50 Mhz TIM3->PSC = 65535; TIM3->ARR = 0xFF; TIM3->CR1 = TIM_CR1_URS; TIM3->DIER = TIM_DIER_UIE ; // enable update interrupts only TIM3->EGR = TIM_EGR_UG; // enable update generation TIM3->CR1 |= TIM_CR1_CEN; // enable counter NVIC_EnableIRQ(TIM3_IRQn); NVIC_SetVector(TIM3_IRQn, (uint32_t)&TIM3_IRQHandler); while (1) ; } void TIM3_IRQHandler() // interrupt routine { GPIOA->ODR^= 0x0001; TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag }