AnsweredAssumed Answered

watchdog handler

Question asked by sullacorda on Jul 3, 2015
Latest reply on Jul 4, 2015 by sullacorda
Hello,
I'm trying to develop a watchdog handler to catch, as for exceptions, the last code executed before watchdog. To do that I tried to copy the handler I did for faults and that I found on web.

  asm(   "TST LR, #4 \n"
      "ITE EQ \n"
      "MRSEQ R0, MSP \n"
      "MRSNE R0, PSP \n"
      "B HalWdt_Save_Reg_c \n"
  );

My application runs partially under OS, uC-os III, with some Irqs under OS, and partially under direct Irq, out of OS. The problem I'm experiencing is that the first check done to decide if I have to use the PSP or the MSP it's not working correctly. I checked the OS and the CONTROL[1] is set to 1 so normally under irq it should use the MSP while in thread mode it should use the PSP, as far as I understood.
I debug a little bit and when I go in the watchdog irq it correctly does the check at the beginning and it chooses the PSP based on LR but the correct data are on MSP.
I don't know if I'm missing something or if the check should be done in a different way.
My toolchain is IAR.

thanks
michele

Outcomes