Help, COP settings

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,316件の閲覧回数
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

ラベル(1)
1 解決策
1,073件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

1 返信
1,074件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------