Seema Rane

Problem to achieve the functionality of  COP in mc9s12xdp512

Discussion created by Seema Rane on Jun 16, 2008
Latest reply on Jun 18, 2008 by Seema Rane
I am facing a problem o achieve the functionality of COP with  mc9s12xdp512 controller
I am trying to test the COP functionality and the code is as follows,
void main(void) {
  DDRB = 0x0F; /* for port initialization */
  COPCTL =  0x07; /* cop initialization*/

  /* put your own code here */
  asm_main(); /* call the assembly function */
      /* infinite loop to achieve the watchdog interrupt*/
  } /* wait forever */
  /* please make sure that you never leave this function */
/* watchdog interrupt function added in the vector table*/
void WDG_RESET_ISR(void)  / * ISR for COP, and is at initialised at  VECTOR 2 */
    PORTB_PB0 = 0x01;  /* Port B0 should  glow when this ISR is called*/ 
In the main code i have set (enable)the COP(0x07) with count for 4sec for 4MHz oscillator . but i observe that after 4 seconds COPCTL becomes 0x00 and it goes to inifinite loop and if i observe in debugger that it goes to LDS instruction with address 0xFFFF (unknow ) location, and stays in inifinte loop.
In the above code I have done the timeout by using the "for loop"
But i actuall want an WDG_RESET_ISR function to be call and the port B0 to glow on COP timeout.
Please let me know whether there are any other register to be taken care or i have not implemented it correctly.