Help, COP settings

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

Help, COP settings

Jump to solution
1,319 Views
Molibdeno
Contributor II

hi
I'm using HCS12 (MC9S12E256) and do not understand how are the settings of the COP to use the interrupt and how are the setting for CPU reset

I have to call the interrupt when overflow COP but the CPU is reset ... where am I wrong


Thank you

Labels (1)
1 Solution
1,076 Views
RadekS
NXP Employee
NXP Employee

Hi marcobarison,

COP watchdog do not generate the interrupt. It directly reset MCU.

The COP reset vector could be the same as POR reset vector. In that case, we could simply define this reset vector in prm linker file. For example:

VECTOR 0 _Startup /* POR reset vector: this is the default entry point for a C/C++ application. */

VECTOR 1 _Startup /* CM reset vector: this is the default entry point for a C/C++ application. */

VECTOR 2 _Startup /* COP reset vector: this is the default entry point for a C/C++ application. */

If we want different startup code than startup for power on, we could define COP reset vector similar way how interrupt. For example:

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

// COP reset

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

#pragma CODE_SEG NON_BANKED

interrupt 2 void COP_ISR(void)

{

    DDRA = 0xff;

    PORTA = 0x00;          //LEDs on - show we entered the COP_ISR    

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

    {

        asm nop;

    }

    PORTA = 0xff;

    asm jmp _Startup;      //jump to power-on reset vector

    // !!! RTI instruction cannot be executed because this is not interrupt !!!

}

#pragma CODE_SEG DEFAULT

Note: detection of COP reset depends also on capacitance on RESET pin. For more details please look at https://community.freescale.com/docs/DOC-103737


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

1 Reply
1,077 Views
RadekS
NXP Employee
NXP Employee

Hi marcobarison,

COP watchdog do not generate the interrupt. It directly reset MCU.

The COP reset vector could be the same as POR reset vector. In that case, we could simply define this reset vector in prm linker file. For example:

VECTOR 0 _Startup /* POR reset vector: this is the default entry point for a C/C++ application. */

VECTOR 1 _Startup /* CM reset vector: this is the default entry point for a C/C++ application. */

VECTOR 2 _Startup /* COP reset vector: this is the default entry point for a C/C++ application. */

If we want different startup code than startup for power on, we could define COP reset vector similar way how interrupt. For example:

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

// COP reset

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

#pragma CODE_SEG NON_BANKED

interrupt 2 void COP_ISR(void)

{

    DDRA = 0xff;

    PORTA = 0x00;          //LEDs on - show we entered the COP_ISR    

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

    {

        asm nop;

    }

    PORTA = 0xff;

    asm jmp _Startup;      //jump to power-on reset vector

    // !!! RTI instruction cannot be executed because this is not interrupt !!!

}

#pragma CODE_SEG DEFAULT

Note: detection of COP reset depends also on capacitance on RESET pin. For more details please look at https://community.freescale.com/docs/DOC-103737


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------