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
解決済! 解決策の投稿を見る。
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!
-----------------------------------------------------------------------------------------------------------------------
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!
-----------------------------------------------------------------------------------------------------------------------