Try this simple C program; add a breakpoint when at the assignment to ARMCOP.
void @near main (void) { COPCTL=0x40; COPCTL=0x43; ARMCOP=6; while(1) { } }
If the software begins from an external reset COPCTL will contain the value 0x43 prior to setting ARMCOP=6.
However, after the ARMCOP reset, COPCTL will contain the value 0x40, and the assignment to ARMCOP will no longer cause a reset.
According to the datasheet describing the COPCTL fields
Writing CR[2:0] to “000” has no effect, but counts for the “write once” condition.
I expect when ARMCOP=6; is reached COPCTL would always contain the value 0x40.
Specifically tested on an MC9S12XS128 Mask 1M04M.
While this is a simple example, assigning ARMCOP an invalid value is used by the full software to trigger a reset on demand. COPCTL=0 was placed in an earlier module during development and was mistakenly not removed. causing the second reset request to fail.
Solved! Go to Solution.
Hi,
if you debug the MCU it is clear you are not in normal mode but in the special mode.
Write:
— Anytime in special modes
Moreover, I suggest you to look at https://community.nxp.com/docs/DOC-103737
plus attached example.
Best regards,
Ladislav
Hi,
if you debug the MCU it is clear you are not in normal mode but in the special mode.
Write:
— Anytime in special modes
Moreover, I suggest you to look at https://community.nxp.com/docs/DOC-103737
plus attached example.
Best regards,
Ladislav
Thank you, I attempted again using an oscilloscope on PORTA pin 1, and running from power up with the debugger disconnected.
I was able to confirm that COPCTL can only be written to once when the debugger is not connected.
void _at(near) main (void){ unsigned short i,j; DDRA = 1u << 1; /* High->Low->High pulse for the oscilloscope */ PORTA = 0xFFu; for(i=0;i<1000;i++){ (volatile void)__asm("NOP"); } PORTA^=0xFFu; for(i=0;i<4000;i++){ (volatile void)__asm("NOP"); } PORTA^=0xFFu; for(i=0;i<1000;i++) { (volatile void)__asm("NOP"); } PORTA^=0xFFu; COPCTL = 0x40u; COPCTL = 0x43u; ARMCOP = 6u; /* Create 10 edges (5 pulses) */ for(j = 0u; j < 10; j++) { for(i=0;i<1000;i++) { (volatile void)__asm("NOP"); } PORTA^=0xFFu; } /* End with logic 1 */ PORTA=0xFFu; while(1) {} }