cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RE goes into infinite loop when interrupts are enabled.

CMcC.1
Associate II

I am not sure why but the moment I enable this interrupt the debugger goes to this file and just sits there. What is interesting is the stack trace changes if there are certain functions involved but the error never changes. So I removed all the functions but this still happens.

ERROR where debugger breaks

ENDS IN A DEBUG breakPoint here in startup_stmf32f401retx.s /** * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. * * @param None * @retval : None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: Infinite_Loop: b Infinite_Loop 

This is the stack trace

Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap) UsageFault_Handler() at startup_stm32f401retx.s:101 0x8000630 () at 0xfffffff1 0x0 () at 0xfffffff9 stepper_init() at stepperpwm.c:18 0x80001ea main() at main.c:38 0x8000530 Reset_Handler() at startup_stm32f401retx.s:83 0x8000616

This is my code

main () { 
    housekeeping_init(); 
    while() { 
        housekeeping(); 
        } 
} 
        
void housekeeping_init() { 
    __disable_irq(); 
    RCC->AHB1ENR |= 1;
    //(1 << 0); 
    //TIM5 RCC->APB1ENR |= (1 << 3);
    TIM5->PSC = 1000-1; 
    TIM5->ARR = 10-1; 
    TIM5->DIER |= 1; 
    NVIC_SetPriority(TIM5_IRQn,2); 
    NVIC_EnableIRQ(TIM5_IRQn); 
    GPIOA->MODER |= 1; 
    __enable_irq(); 
    TIM5->CR1 |= 1; 
} 
 
void TIM5_IRQHandler() { 
    //TIM5->SR &= ~(1); 
    TIM5->SR &= ~0x01; 
    //TIM5->SR = 0; 
    GPIOA->ODR ^= 1;
     ***++; 
} 
 
void housekeeping() { 
    if (*** == 300) { 
        GPIOA->ODR ^= 1; 
    } 
}

0 REPLIES 0