AnsweredAssumed Answered

S32K148 - Cannot program or erase flash

Question asked by Tomas Frcek on Apr 11, 2018
Latest reply on Aug 2, 2018 by Adithya Manjunath

Hello,

 

I am using Keil IDE and Keil ULINKPro probe to program S32K148. I added Watchdog function to my application as described in the reference manual:

 

int main(void)

{

      WDOG->CNT = 0xD928C520;                      //unlock watchdog
      WDOG->CS &= ~WDOG_CS_EN_MASK;  //disable watchdog

 

      // Modules initialization

      ...

 

      WDOG->CNT = 0xD928C520;                                                    //unlock watchdog
      while((WDOG->CS & WDOG_CS_ULK_MASK) == 0) { ; }        //wait until registers are unlocked
      WDOG->TOVAL = 256;                                                                //set timeout value
      WDOG->CS = WDOG_CS_EN(1) | WDOG_CS_CLK(1) | WDOG_CS_INT(1) | WDOG_CS_WIN(0) |       WDOG_CS_UPDATE(0);
      while((WDOG->CS & WDOG_CS_RCS_MASK) == 0);             //wait until new configuration takes effect

 

      while (1)

      {

            IRQ_Disable(); // disable global interrupt
            WDOG->CNT = 0xB480A602; // refresh watchdog
            IRQ_Enable(); // enable global interrupt

 

            // main loop

            ...

      }

}

 

However after programming I can no longer program or erase the MCU flash using the Keil IDE (I only get the SWD communication error message). I susspect my watchdog initialization or feeding mechanism is wrong and the MCU is stuck in some kind of a reset loop.

 

Is there something terribly wrong with the watchdog in my application? And is there a way to erase the MCU flash so that I can access it again?

 

Thanks!

Outcomes