PDA

View Full Version : Hc12 Cop


Dick
12-11-01, 01:31 PM
I have been trying to write a cop routine that would result in a reset of
the processor . So far no success !
Your comments and any suggestions re the following code would be much appreciated .
Sincerly
Dick Henderson
\ ************************************************************************
\ ***\ Turn COP on if input from switch is hi else leave alone ***
\ ************************************************************************

COLD
HEX
: COP-ON
6F C@ 80 AND \ ck sw connected to Bit 7 of PORTAD
IF
7 16 C! 16 C@ .
." Turn Cop on "
ELSE
." Cop is off" \ if pad7 is low on reset I see same as above
THEN
; EEWORD

' COP-ON CFA FFC EE! \ CFA of cop-on -> 0FFC for quick start procedure

A55A FFE EE! \ Set up quick start

: EEC, ( ....) \ compiles n into eeprom incremente EDP
EDP DUP @ ROT SWAP EEC! 1+!
;

FF8 EDP ! \
06 EEC, \ JMP ( the restart vector fc00 -> PC )
FC EEC, \ I thought that this would result in a reset
00 EEC,

0F F7FA FLC! \ address of COP handler -> secondary vector
F8 F7FB FLC!


\ ************************************************************************
\ *** Results ***
\ ************************************************************************

\ if pad7 is hi on reset I see one occurence only of
\ Cop is on
\ Max-FORTH V5.0L
\ I had expected to see repeated occurences each time the cop timed out?
\ ****
\ if pad7 is low on reset I see one occurence only of
Cop is off
Max-FORTH V5.0L
\ This is the result that I expected.

\ ************************************************************************
\ *** Some Dumps of relative memory are below ***
\ ************************************************************************


12/20/01 08:19:58
Capturing to Screen: ~ Exits...

FFF0 10 DUMP
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
FFF0: FC 69 FC 6D FC 71 FC 75 FC 79 FC 7D FC 81 FC 00 .i.m.q.u.y.}.... OK


0FF0 10 DUMP
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
FF0: FF FF FF FF FF FF FF FF 06 B8 04 FF 0D 0B A5 5A ...............Z OK



F7F0 10 DUMP \ address of cop handler in F7FA-B
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
F7F0: FF FF FF FF FF FF FF FF FF FF 0F F8 FF FF B8 04 ................ OK