About Watchdog reset for S12ZVML128 controller.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About Watchdog reset for S12ZVML128 controller.

1,045 Views
pratibhasurabhi
Contributor V

Hi,

I want to test Watchdog reset abnormality for S12ZVMl128.

Accoarding to me, when I will write garbage value other than 0x55 and 0xAA to CPMUARMCOP register watchdog will get reset and the COPRF flag will be raised.

In my code,when i write garbage value to CPMUARMCOP register the EEPROM will get written by oxEE.

So I am not getting this behaviour why this is happening,Please provide some solution for this.

0 Kudos
3 Replies

563 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

the triangle, in front of value EE (in the memory window), says that the value is not updated/refreshed/known. The reason is the COP and communication with PC. The COP is normally not debuggable because it is an reset and the communication between debugger and MCU is lost. The best way is to debug and set behavior of the CPU at the beginning of the project and then implement it into a project. Next possible debugging is to signalize COP by diodes or use UART (SCI) for sending messages to a PC. I usually use diodes as presented below (tested on TRKS12ZVL). If you want to see correct behavior of the COP the most suitable way is to disconnect BDM from the board and start the MCU by power on or reset button.

If my explaation is not clear do not hesitate to contact me again.

//------------------------------------------------------------------------------
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
//------------------------------------------------------------------------------
#define LED_ID_BLUE          1
#define LED_ID_BLUERED       4
#define LED_ID_BLUEGREEN     6

#define LED_ID_RED           3
#define LED_ID_REDBLUE       4
#define LED_ID_REDGREEN      8

#define LED_ID_GREEN         5
#define LED_ID_GREENBLUE     6
#define LED_ID_GREENRED      8

#define LED_ID_BLUEREDGREEN  9

#define LED_BLUE             PTP_PTP1
#define LED_RED              PTP_PTP3
#define LED_GREEN            PTP_PTP5
#define ON                   0
#define OFF                  1
#define LED_OFF_BLUE         PTP_PTP3 = OFF;
#define LED_OFF_RED          PTP_PTP1 = OFF;
#define LED_OFF_GREEN        PTP_PTP5 = OFF;
#define LED_ON_BLUE          PTP_PTP3 = ON;
#define LED_ON_RED           PTP_PTP1 = ON;
#define LED_ON_GREEN         PTP_PTP5 = ON;
//------------------------------------------------------------------------------
void blink(unsigned char led_id, unsigned long rpt, unsigned long dly);
void delay(unsigned long dly);
//------------------------------------------------------------------------------
void blink(unsigned char led_id, unsigned long rpt, unsigned long dly)
{
  rpt = rpt * 2;
 
  while(rpt--)
     {
       // blue   
       if(led_id == LED_ID_BLUE || led_id == LED_ID_BLUERED || led_id == LED_ID_BLUEGREEN || led_id == LED_ID_BLUEREDGREEN)  
                            LED_BLUE = (LED_BLUE == 1) ? 0 : 1;    

       //red
       if(led_id == LED_ID_RED || led_id == LED_ID_REDBLUE || led_id == LED_ID_REDGREEN || led_id == LED_ID_BLUEREDGREEN)  
                            LED_RED  = (LED_RED == 1) ? 0 : 1;    

       //green
       if(led_id == LED_ID_GREEN || led_id == LED_ID_GREENBLUE || led_id == LED_ID_GREENRED || led_id == LED_ID_BLUEREDGREEN)  
                            LED_GREEN = (LED_GREEN == 1) ? 0 : 1;    

       delay(dly);
     }
}
//------------------------------------------------------------------------------
void delay(unsigned long dly)
{
  while(dly--)
            asm nop;
}
//------------------------------------------------------------------------------
void main(void)
{
  //-------------------------------
  DDRP_DDRP1 = 1;                  //LEDBLUE  PORT
  DDRP_DDRP3 = 1;                  //LEDRED   PORT
  DDRP_DDRP5 = 1;                  //LEDGREEN PORT
  //-------------------------------
  LED_OFF_BLUE;
  LED_OFF_RED;
  LED_OFF_GREEN;
  //-------------------------------
  blink(LED_ID_BLUE,1,0x1FFFF);
  blink(LED_ID_BLUERED,1,0x1FFFF);
  blink(LED_ID_BLUEGREEN,1,0x1FFFF);
  blink(LED_ID_RED,1,0x1FFFF);
  blink(LED_ID_REDGREEN,1,0x1FFFF);
  blink(LED_ID_GREEN,1,0x1FFFF);
  blink(LED_ID_BLUEREDGREEN,1,0x1FFFF);
//-------------------------------
  if (CPMURFLG_COPRF)
    {
       blink(LED_ID_BLUE,5,0x3FFFF);
    }
  //-------------------------------
  if (CPMURFLG_PORF)
    {
       blink(LED_ID_RED,5,0x1FFFF);
    }
  //-------------------------------
  CPMURFLG = 0x6B; //clear all flags

  for(;;)
   {
      CPMUCOP=0x07;             //init COP watchdog
      CPMUARMCOP=0x00;          //immediate reset MCU
    
   }
  //-------------------------------
}
//------------------------------------------------------------------------------

0 Kudos

563 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

the S12Z family device reset source recognition is not affected by size of capacitor at the reset pin as it was for older types of S12 devices so there should not be any potential issue or problem with recognition.

Writing any vale to the EEPROM where initial COP setup value can be stored has no meaning for immediate COP reset.

Immediate reset is generated by writing any value to CPMUARMCOP in the registers.

CPMUARMCOP = 0xXX; // any value different from 0x55, 0xAA number flow.

I am sorry but I do not understand the sentence:

"In my code,when i write garbage value to CPMUARMCOP register the EEPROM will get written by oxEE."

...part "the EEPROM will get written by 0xEE."

??? CPMUARMCOP does not changes EEPROM. The EEPROM can only store initial value for COP period in the FOPT space which is loaded into CPMUCOP in inverted value during reset. (see 1.12.1 CPMU COP and GDU GSUF Configuration)

So, could you please send me short example what you are doing to better understand your issue.

An simple example of reset source recognition:

void main(void)

{

  EnableInterrupts;
  /* include your code here */
  PTS=0x00;
  DDRS_DDRS4=1;  //LED1
  DDRS_DDRS5=1;  //LED2
 
  if (CPMURFLG_COPRF)
    {
      PTS_PTS4=1;
    }
  if (CPMURFLG_PORF)
    {
      PTS_PTS5=1;
    }
  CPMURFLG = 0x6B; //clear all flags

  for(;;)

  {
  if (PTP_PTP1==0)
    {
      CPMUCOP=0x07;  //init COP watchdog
      CPMUARMCOP=0x00;   //immediate reset MCU
    }
    
  } /* loop forever */
  /* please make sure that you never leave main */

}

Best regards,

Ladislav

0 Kudos

563 Views
pratibhasurabhi
Contributor V

Thanks Lama !

#define COP_WDG_RESET_TEST

int main(void)

{

   ChkWtdRstFailsafe();
   EnableInterrupts;

/* other function calls  like HW initialization*/

Ifdef  COP_WDG_RESET_TEST

      // Feeding nothing will reset the COP Watchdog

#else
     CPMUARMCOP = 0x55;
     CPMUARMCOP = 0xAA;

#endif

}

Init_CPU()

{

   /* COPOSCSEL0 = 1 : to select OSCCLK as a clock source */
   CPMUCLKS |= 0x01;
   /* RSBCK = 1 : Stops the COP and RTI counters in Active BDM mode, CR[2:0] = 0x7 : 2^24 COPCLK Cycles for watchdog time-out */
   CPMUCOP = 0x47;

   CPMUHTCTL_HTE = 1;

}

void ChkWtdRstFailsafe()

{

   if(CPMURFLG & CPMURFLG_COPRF_MASK)
   {
      /* failsafe detection logic */
      CPMURFLG_COPRF = CLEAR_FLAG;

}

Above is the part of my code for watchdog test.

When enabled the macro COP_WDG_RESET_TEST and after running the code the EEPROM will get written by 0XEE as below,

pastedImage_34.png

I am not getting the reason behind this.

Please help me for the same.

0 Kudos