ncs wdt handler

How to use a custom wdt interrupt routine in ncs, because I need to record my pc pointer in the wdt interrupt routine, just like in nrf5 sdk:

void WDT_IRQHandler_real(uint32_t *sp)
{
    /* PC is sp[6]*/
    //R0、R1、R2、R3、R12、LR、PC、XPSR
    uint32_t pc_address = sp[6];
    if (nrf_wdt_event_check(NRF_WDT_EVENT_TIMEOUT))
    {
        nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT);
    }
    ram_remain_info.wdt_pc_addr = pc_address;
    //remian_info_sync();
}

void WDT_IRQHandler(void) __attribute__((naked));
/* Cortex M3/4 */
void WDT_IRQHandler()
{
    asm volatile(
        "TST   LR, #4\n\t"
        "ITE   EQ\n\t"
        "MRSEQ R0, MSP\n\t"
        "MRSNE R0, PSP\n\t"
        "LDR   R1, =WDT_IRQHandler_real\n\t"
        "BX    R1");
}

Parents Reply
  • I added the sample code for this case, and I tested it myself by calling while(1) somewhere to block the application. It works and outputs the address before the watchdog reset. But my normal application has also had several watchdog resets, and it does not work because the register content is not valid and cannot give me the information I want. Do you know why it does not work? Is there any limitation?

Children
No Data
Related