2014-01-09 04:14 AM
In order to test the Hard Fault interrupt, I modified the Systick example on ''STM32F0xx_Discovery_FW_V1.0.0'' as follows..
on main.c I added two lines: ------------------------------ int main(void) { uint8_t* BytePtr = (uint8_t)0x20002000; *BytePtr = 0x5a; //generate hardfault IRQ /*!< ...........comment */ /* Initialize Leds mounted on STM32F0-discovery */ STM_EVAL_LEDInit(LED3); -------------------------------------- on stm32f0xx_it.c I modified the error handler: ----------------------------------- void HardFault_Handler(void) { TimingDelay_Decrement(); //really do nothing... } --------------------------------------- So, when the line *BytePtr = 0x5a; is executed and the processor access the wrong location 0x20002000 a HardFault_Handler is called and executed. At return I expect the processor to execute the line STM_EVAL_LEDInit(LED3); but instead it returns still at line ''*BytePtr = 0x5a; and newly execute it, entering in loop!!! I am a novice on STM32 so it must be a stupid error but if I repeat the same test on the ''STM32F10x_vldiscovery_package'' it works as expected... Can someone help me?? Thanks, Luciano2014-01-09 04:45 AM
Hi
RTI - Return from Interrupt will load the Program Counter with the value before/at the IRQ trigger. Since the IRQ was cause at line ''*BytePtr = 0x5a;'' That is where it will return. That is why the ISR for HardFault is usually an infinite loop. Nice experiment though - never thought of doing this myself2014-01-09 05:32 AM
If you repeat this experiment on ''STM32F10x_vldiscovery_package''
(stm32f100 cortex m3) il works well, NOT entering in loop!!! You are telling me that on stm32f0xx (cortex M0) the ''Return from Interrupt will load the Program Counter with the value before/at the IRQ trigger'' but on stm32f100 (cortex M3) Return from Interrupt will load the Program Counter with the value AFTER the IRQ trigger??? Very strange thing....2014-01-09 06:09 AM
Hi
''You are telling me that on stm32f0xx (cortex M0) the ''Return from Interrupt will load the Program Counter with the value before/at the IRQ trigger'' but on stm32f100 (cortex M3) Return from Interrupt will load the Program Counter with the value AFTER the IRQ trigger'' No, Im telling you that in GENERAL RTI SHOULD return you to the exactly where the code was before the IRQ. Other wise IRQs would cause strange differences in behaviour when they go off and pause the flow of execution. No comment on the difference between the result on the 2 processors - I do not know why.