Question
Interrupt Problem
Posted on October 17, 2010 at 11:32
hi i am trying to activate the Tim2 Interrupt but for some reason it does not work here is the program i wrote:
#include ''stm32F10x.h'' void setsystemclock(void); void TIM2_IRQHandler(void); int main(void) { setsystemclock(); //set system clock to 24Mhz //rcc configuration RCC->APB1ENR=RCC_APB1RSTR_TIM2RST;//tim2 enable RCC->APB2ENR=RCC_APB2ENR_IOPCEN;//portc Clock enable //nvic configuration NVIC_EnableIRQ(TIM2_IRQn); //GPIO configuration GPIOC->CRL=0x33000000;//ports 6,7 as fast output GPIOC->CRH=0x33;//ports 8,9 as fast output //tim Configuration TIM2->ARR=65535; TIM2->EGR=TIM_EGR_UG;/*!<Update Generation */ TIM2->CCMR1=0; TIM2->CCR1=40961; TIM2->CCER=TIM_CCER_CC1E; /*!<Capture/Compare 1 output enable */ TIM2->CCMR1=0; TIM2->DIER=TIM_DIER_CC1IE ;/*!<Capture/Compare 1 interrupt enable */ TIM2->CR1=TIM_CR1_CEN;/*!<Counter enable */ while(1) { } } void TIM2_IRQHandler(void) { TIM2->SR=~TIM_SR_CC1IF; //Clears the TIMx's interrupt pending bits. GPIOC->ODR^=0xC0; } void setsystemclock(void) { RCC->CR |= RCC_CR_HSEON; // Wait until it's ready while ((RCC->CR & RCC_CR_HSERDY) == 0) ; // Select PREDIV1 as PLL source and sett PLL mul to 3 (set bit 0) // for 8*3 = 24 MHz RCC->CFGR |= RCC_CFGR_PLLSRC | RCC_CFGR_PLLMULL_0; // Start PLL RCC->CR |= RCC_CR_PLLON; // Wait until it's ready while ((RCC->CR & RCC_CR_PLLRDY) == 0) ; // Select PLL as system clock RCC->CFGR |= RCC_CFGR_SW_PLL; // Here we can check if PLL is used, and maybe disable HSI // Disable HSI RCC->CR &= ~RCC_CR_HSION; RCC->CFGR|=RCC_CFGR_MCO_2; //sys clock output } what did i do wrong? thanks for your help. i get the following error: BusFault_Handler: DebugMon_Handler: HardFault_Handler: MemManage_Handler: NMI_Handler<26731 (failed: LoadStrW)>: 0x800018c: 0xe7fe B.N BusFault_Handler ; 0x800018c 0x800018e: 0xffff DC16 65535 ; '..' 0x8000190: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7 0x8000194: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7 0x8000198: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7 0x800019c: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7 0x80001a0: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7 0x80001a4: 0xffffffff MRC2 p15, #7, pc, c15, c15, #7