AnsweredAssumed Answered

COP not working as expected

Question asked by Jairo Berrio on Sep 25, 2014
Latest reply on Oct 21, 2014 by iggi

I am currently using an MC9S12E128 processor and I have a troublesome problem.  If I enable the COP and then move to a loop where I don't reset the COP, I am not vectoring to the

address placed in the "COP monitor fail reset vector" (0xFFFA).  Currently the location 0xFFFA has 0xC00C as the address.  At that address I sit in an endless loop flashing an LED if I don't reset the COP. 

 

I am using CodeWarrior 5.9.0 and when I am debugging the code the debugger stops at address 0x4A4D.  If I disconnect the debugger and do a power reset I never see the software locking up at the endless flashing LED loop, so it's not a debugger issue.

 

At this point I can't get the COP to pull a reset.  What could possibly be going wrong???

 

; code section

            ORG   $C000

Entry:     ldx    #$0500         ;Reset stack pointer

              txs

              ldaa   #$47           ;Enable COP

              staa   COPCTL

 

 

;Endless loop

_Startup:

           nop                  ;Don't reset COP

           bra  _Startup


;**************************************************************

;*                       COP TRAP                                    *

;**************************************************************

        

;COP vector address!!        

COPRes     equ   *

          

           ldaa  #$41       ;LED ON

           staa  PTM

           staa  DDRM

 

            ldx   #$FFFF

Decxs:  dex

            bne   Decxs

 

            ldaa  #$40        ;LED OFF

            staa  PTM

         

            ldx   #$FFFF

Decys:  dex

            bne   Decys

            bra   COPRes      ;Endless branch!!!               

Outcomes