Good morning, I would like to ask some advice from you about the restarting problems of STM32F100.My situation is as following:
I invoked “Reset_Handler” in the main circulation,and the program can operate normally when starting the timer2.However,when I invoked “Reset_Handler” in the HardFault_Handler to restart the chip,the time2 can’t start normally. Is there any special wrong?
The Hard-fault program I invoked by myself:
Code:
HardFault_Handler\
                PROC
                IMPORT  hard_fault_handler_c
                                TST LR, #4
                                ITE EQ
                                MRSEQ R0, MSP
                                MRSNE R0, PSP
                                B        hard_fault_handler_c
                ENDP
The handling functions:
Code:
void hard_fault_handler_c(unsigned int * hardfault_args)
{
        static T_CALL_STACK T_stacked;

        T_stacked.stacked_r0 = ((unsigned long) hardfault_args[0]);
        T_stacked.stacked_r1 = ((unsigned long) hardfault_args[1]);
        T_stacked.stacked_r2 = ((unsigned long) hardfault_args[2]);
        T_stacked.stacked_r3 = ((unsigned long) hardfault_args[3]);
        T_stacked.stacked_r12 = ((unsigned long) hardfault_args[4]);
        
        T_stacked.stacked_lr = ((unsigned long) hardfault_args[5]);         
        T_stacked.stacked_pc = ((unsigned long) hardfault_args[6]);
        T_stacked.stacked_psr = ((unsigned long) hardfault_args[7]);

        T_stacked.SHCSR = (*((volatile unsigned long *)(0xE000ED24)));
        T_stacked.MFSR = (*((volatile unsigned char *)(0xE000ED28)));        
        T_stacked.BFSR = (*((volatile unsigned char *)(0xE000ED29)));        
        T_stacked.UFSR = (*((volatile unsigned short int *)(0xE000ED2A)));
        T_stacked.HFSR = (*((volatile unsigned long *)(0xE000ED2C)));  
        T_stacked.DFSR = (*((volatile unsigned long *)(0xE000ED30)));        
        T_stacked.MMAR = (*((volatile unsigned long *)(0xE000ED34)));        
        T_stacked.BFAR = (*((volatile unsigned long *)(0xE000ED38))); 
        
        FlashRecord(&T_stacked);
        while (1) Reset_Handler();
Could you give me some suggestions? Thanks.
Have a nice day~