2010-10-17 02:32 AM
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, #72010-10-17 05:32 AM
Seems to build and run under Keil uv4.
TIM2 Interrupts periodically The code enabling the PLL does not properly mask and set bits, and does not wait for the PLL to be selected as the source clock. Try to determine what address is faulting in your code.2010-10-17 05:35 AM
2010-10-17 06:30 AM
2010-10-17 07:08 AM
how can i determine what address is faulting in my code?
Single Step, Trace, Bisection, Instrumentation, or check the fault state the Cortex-M3 pushes onto the stack.and why cant i set breakpoint in void TIM2_IRQHandler(void)? Because the tool you are using sucks? You can't set one, or it's not hitting it?2010-10-17 07:11 AM
i am using IAR Embedded Workbench it says
One or more breakpoints could not be set and have been disabled. when i run the program with breakpoint already set, and when i try to set it when i ran the program it does not let me. how can i check the fault state the Cortex-M3 pushes onto the stack? thanks2010-10-17 07:14 AM
2010-10-17 10:45 AM
i am using IAR Embedded Workbench it says, One or more breakpoints could not be set and have been disabled.
So the tool does suck, the chip should have 6-8 breakpoints, I don't think the STM32F100 (LV) has a reduced set, but can't find a good cite. The code as presented pretty much pastes into the demo/eval version of Keil uv4 and works as is. And you can breakpoint the interrupt. how can i check the fault state the Cortex-M3 pushes onto the stack? Add code to automate it, or just look at the registers, and dump memory regions within the debugger. You are interested in the PC (R15) when it faulted.https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM CortexM3 STM32/HardFault Exception Why oh why!&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E¤tviews=2772
when i checked the cstack in the tracer i saw the address 0x200003B8 what does it means? The stack is in RAM, you could view it in the debugger. Depending on how it faulted either the system or user stack will contain the fault data.2010-10-17 11:44 PM
2010-10-17 11:58 PM