Question
TIM3 interrupt BusFault_Handler
Posted on February 10, 2014 at 18:16
Hi all,
I'm new to STM32 and i'm having some problems with making TIM3 interrupt work on my STM32F3DISCOVERY. The problem is that when i run the code on the discovery i get in the BusFault_Handler.My code:
GPIO_InitTypeDef GPIO_InitStruct; TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct; NVIC_InitTypeDef NVIC_Struct; void TIM3_IRQHandler(void) { if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set { TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag GPIOE->ODR ^= (1<<7); } } int main(void) { RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE|RCC_AHBPeriph_GPIOA, ENABLE); GPIO_InitStruct.GPIO_Pin = GPIO_Pin_All; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOE, &GPIO_InitStruct); /******************************************************************** TIM3 code bellow *********************************************************************/ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_TimeBaseInitStruct.TIM_Prescaler = 7999; TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInitStruct.TIM_Period = 1000; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseInitStruct); TIM_ClearFlag(TIM3, TIM_FLAG_Update); TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); TIM_Cmd(TIM3, ENABLE); /******************************************************************** NVIC code bellow *********************************************************************/ NVIC_Struct.NVIC_IRQChannel = TIM3_IRQn; NVIC_Struct.NVIC_IRQChannelPreemptionPriority = 0; NVIC_Struct.NVIC_IRQChannelSubPriority = 1; NVIC_Struct.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_Struct); NVIC_EnableIRQ(TIM3_IRQn); while (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0) == 0); GPIO_WriteBit(GPIOE, GPIO_Pin_8, Bit_SET); while(1) { } return 0; } Any suggestions? Thanks in advance!