How to enable COP reset for MC9S12ZVM?

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

How to enable COP reset for MC9S12ZVM?

Jump to solution
970 Views
young-kyunpark
Contributor II

How can I enable COP for MC9S12ZVM? or How can I jump to reset vector address when I need It?

 

Here is my configuration for COPCTL ;

 

CPMUCLKS_COPOSCSEL0 = 0;

  CPMUCLKS_COPOSCSEL1 = 1;

  CPMUCLKS_CSAD = 1;

  CPMUCOP_WRTMASK = 0;

  CPMUCOP_CR = 0x01;

  CPMUCOP_WCOP = 0;

  CPMUCOP_RSBCK = 1;

 

but, MCU working without reset.

 

regarding calling reset vector,

someone reply about jump to reset vector as follow

((void (*__near)(void))0xFFFE)();

but this line occurs syntex error.

Labels (1)
1 Solution
594 Views
iggi
NXP Employee
NXP Employee

Hi Young-kyun,

Watchdog is enabled by a write to the CPMUCOP register i.e. by writing a nonzero value to COP Watchdog Timer Rate Select bits - CR[2:0]. This action enables the COP counter and start the time-out period.
Below is a very simple code performing watchdog reset tested on S12ZVM EVB. The COP source clock is ACLK. The COP time-out period is set to maximum, so the time between two resets is around 13sec. This will be indicated by LED blink.

//******************************************************************************

// Main program

//******************************************************************************

void main(void) {

   

    unsigned int i;

   

    CPMUCLKS_COPOSCSEL1 = 1; // COP clock source is ACLK

 

     DDRS = 0xff;                             // Port S set as output   

     PTS  = 0x00;                             // LEDs off

 

  for(i=0; i<60000; i++)                    // delay

     {

         asm nop;

         asm nop;

         asm nop;

     }

 

     PTS  = 0xff;                             // LEDs on

 

    CPMUCOP = 0x47;                  // Enable watchodg 

  for(;;) {} /* wait forever */

 

}

Regarding the jump to reset vector, actually the address is 0xFFFC. You can also use "asm jmp _Startup;"

Regards,

iggi

View solution in original post

1 Reply
595 Views
iggi
NXP Employee
NXP Employee

Hi Young-kyun,

Watchdog is enabled by a write to the CPMUCOP register i.e. by writing a nonzero value to COP Watchdog Timer Rate Select bits - CR[2:0]. This action enables the COP counter and start the time-out period.
Below is a very simple code performing watchdog reset tested on S12ZVM EVB. The COP source clock is ACLK. The COP time-out period is set to maximum, so the time between two resets is around 13sec. This will be indicated by LED blink.

//******************************************************************************

// Main program

//******************************************************************************

void main(void) {

   

    unsigned int i;

   

    CPMUCLKS_COPOSCSEL1 = 1; // COP clock source is ACLK

 

     DDRS = 0xff;                             // Port S set as output   

     PTS  = 0x00;                             // LEDs off

 

  for(i=0; i<60000; i++)                    // delay

     {

         asm nop;

         asm nop;

         asm nop;

     }

 

     PTS  = 0xff;                             // LEDs on

 

    CPMUCOP = 0x47;                  // Enable watchodg 

  for(;;) {} /* wait forever */

 

}

Regarding the jump to reset vector, actually the address is 0xFFFC. You can also use "asm jmp _Startup;"

Regards,

iggi