PDA

View Full Version : Timer interupt and EEPROM writes


MLCarter
10-28-01, 02:24 PM
Hello,
I'm having problems when using an interrupt for timing on a x020 HC11 and updating EEPROM values while the interrupt is active. e.g. code:

' timer interrupt which increments CNT by 1

CODE SIR-TIME
86 C, 80 C,
B7 C, TFLG2 ,
CC C, 01 ,
F3 C, CNT ,
FD C, CNT ,
3B C,
END-CODE

CODE-SUB +INT 0E C, 39 C, END-CODE
CODE-SUB -INT 0F C, 39 C, END-CODE

: ON -INT ['] SIR-TIME @ 100 /MOD 7E B7CB EEC! B7CC EEC! B7CD EEC!
80 TMSK2 C! +INT ;

' a keypad routine which adds or subtracts 1 from the existing EEPROM value

: KPALT FINDEX C@ 2 * B631 + @
KPCHAR C@ 14 = IF 1 - DUP 0 < IF DROP 365 THEN DUP RLCD3D THEN
KPCHAR C@ 18 = IF 1 + DUP 365 > IF DROP 0 THEN DUP RLCD3D THEN
256 /MOD FINDEX C@ 2 * B631 + EEC!
FINDEX C@ 2 * B632 + EEC!
0 KPCHAR C! ;

whenever 2 EEPROM writes are done as above the thing crashs, 1 on its own is OK

Can you see the problem ?

Thank You,
Mark Carter.

30/10 I have now got round the problem by turning the interrupt off while I do the EEC!. My guess is that EEC! is also using the timer interupt for its time delay to allow the EEPROM write to occur which is screwing things up ?