Hello, is there a way to get contents in stack and store them into flash when Hard-fault or NMI happen? If it can't write flash in the situation, is there a mechanism to copy them into a block of SRAM which can be kept even when system has been re-started?
Hi Jerry,Thank you for posting your question on our Online Engineering Community.What data exactly are you interested in saving? In which scenario are you facing a Hard Fault or NMI? The RAM cannot be retained if a power off has occurred. Only the data on the SPI Flash will be saved. In order to save data in the SPI Flash please follow our Tutorial here:DA145XX Tutorial SDK6 Peripheral Drivers — DA145XX Tutorial SDK peripherals (renesas.com)Chapter 5. SPI Flash.Kind Regards,OV_Renesas
Hi OV_renesas,
Thank you for your quick reply. I want to save stack info into flash when Hard Fault happens, so I can analyze the info to find out which function caused it.
In function HardFault_HandlerC, I called the interfaces in spi_flash.c to do erase and write operations, but it didn't work, and nothing has been written into flash. These interfaces have already confirmed to work properly in normal process, so I doubt something needs to be taken care of before calling them in HardFault_HandlerC. Could you please give me some instructions about it?
Thanks,
Jerry