kevinr
10-27-07, 01:11 AM
I have tried many variations on the following code. I have also determined that ' SIR-RTI @ and SIR-RTI leave the same information upon the stack.
Could anyone explain why this code locks the system so hard I need to cycle power so MaxForth is recognized again?
When I comment out the CLI command I can determine the addresses.
' SIR-RTI @ . gives 123E
SIR-RTI . gives 123E
FEF C@ . gives 6
FF0 @ . gives 123E
AFF0 @ . gives FEF
EFF0 @ . gives FEF
But the one which really counts, the actual interrupt vector
FFF0 @ . gives -7E5
Why is it so wildly different from the others which I programmed?
Following along in the provided documents I find the interrupt vectors are in protected Flash as they were with the B32 but the secondary vectors are now much lower in memory and not accessible directly. I must move the F page of Flash into the window and then use AFF0 as the address. This seems to work as shown above. Why is the primary interrupt vector so different?
Why does the system lock up?
The assembly code example provided works correctly but the Forth I've tried to create from the example does not work. Why?
It would be easier and faster to burn MaxForth from the board and program it in assembly. I have wasted well over a week in trying various ways to get the interrupt system to work. An example in MaxForth would be very nice to get past all the traps laid down to catch the unwary. The example in assembly makes it look as simple as it was on previous boards. This one is a stickler.
Code follows:
( RTI2.FTH )
( October 26, 2007 )
( K. J. Rock )
COLD
HEX
30 CONSTANT PPAGE ( programming window page register
37 CONSTANT CRGFLG
38 CONSTANT CRGINT
3B CONSTANT RTICTL
252 CONSTANT DDRM
250 CONSTANT PTM
( VARIABLE ticks
3 DDRM C!
2 PTM C! ( Turn off red LED and green one on )
7F RTICTL C! ( 64 mS timer )
CODE-SUB CLI
10EF , ( CLI ; enable interrupts )
3D C, ( RTS ; continue )
END-CODE
CODE-SUB SEI
1410 , ( SEI ; disable interrupts )
3D C, ( RTS ; continue )
END-CODE
SEI
CREATE SIR-RTI
4D C, CRGFLG C, 7F C, ( BCLR RTIFLG, $7F ; clear RTIF
( 180B , 80 C, CRGFLG C, ( MOVB CRGFLG, $80 ; clear RTIF bit )
( FE C, ticks , ( LDX ticks ; get timer contents )
( 08 C, ( INX ; increment it )
( 7E C, ticks , ( STX ticks ; store it back )
B6 C, PTM C, ( LDAA PTM
88 C, 1 C, ( EORA 1
7A C, PTM C, ( STAA PTM ; toggle red LED
0B C, ( RTI ; return from interrupt )
F PPAGE C! ( page F of flash )
FEF AFF0 FL! ( secondary interrupt vector )
06 FEF EEC! ( 06 is jmp command )
SIR-RTI FF0 EE! ( jmp to interrupt )
80 CRGINT C! ( enable RTI interrupts )
CLI ( enable interrupts )
: BLINK PTM C@ 1 XOR PTM C! ;
: WAIT 5000 0 DO LOOP ;
: T 50 0 DO BLINK WAIT LOOP ;
Could anyone explain why this code locks the system so hard I need to cycle power so MaxForth is recognized again?
When I comment out the CLI command I can determine the addresses.
' SIR-RTI @ . gives 123E
SIR-RTI . gives 123E
FEF C@ . gives 6
FF0 @ . gives 123E
AFF0 @ . gives FEF
EFF0 @ . gives FEF
But the one which really counts, the actual interrupt vector
FFF0 @ . gives -7E5
Why is it so wildly different from the others which I programmed?
Following along in the provided documents I find the interrupt vectors are in protected Flash as they were with the B32 but the secondary vectors are now much lower in memory and not accessible directly. I must move the F page of Flash into the window and then use AFF0 as the address. This seems to work as shown above. Why is the primary interrupt vector so different?
Why does the system lock up?
The assembly code example provided works correctly but the Forth I've tried to create from the example does not work. Why?
It would be easier and faster to burn MaxForth from the board and program it in assembly. I have wasted well over a week in trying various ways to get the interrupt system to work. An example in MaxForth would be very nice to get past all the traps laid down to catch the unwary. The example in assembly makes it look as simple as it was on previous boards. This one is a stickler.
Code follows:
( RTI2.FTH )
( October 26, 2007 )
( K. J. Rock )
COLD
HEX
30 CONSTANT PPAGE ( programming window page register
37 CONSTANT CRGFLG
38 CONSTANT CRGINT
3B CONSTANT RTICTL
252 CONSTANT DDRM
250 CONSTANT PTM
( VARIABLE ticks
3 DDRM C!
2 PTM C! ( Turn off red LED and green one on )
7F RTICTL C! ( 64 mS timer )
CODE-SUB CLI
10EF , ( CLI ; enable interrupts )
3D C, ( RTS ; continue )
END-CODE
CODE-SUB SEI
1410 , ( SEI ; disable interrupts )
3D C, ( RTS ; continue )
END-CODE
SEI
CREATE SIR-RTI
4D C, CRGFLG C, 7F C, ( BCLR RTIFLG, $7F ; clear RTIF
( 180B , 80 C, CRGFLG C, ( MOVB CRGFLG, $80 ; clear RTIF bit )
( FE C, ticks , ( LDX ticks ; get timer contents )
( 08 C, ( INX ; increment it )
( 7E C, ticks , ( STX ticks ; store it back )
B6 C, PTM C, ( LDAA PTM
88 C, 1 C, ( EORA 1
7A C, PTM C, ( STAA PTM ; toggle red LED
0B C, ( RTI ; return from interrupt )
F PPAGE C! ( page F of flash )
FEF AFF0 FL! ( secondary interrupt vector )
06 FEF EEC! ( 06 is jmp command )
SIR-RTI FF0 EE! ( jmp to interrupt )
80 CRGINT C! ( enable RTI interrupts )
CLI ( enable interrupts )
: BLINK PTM C@ 1 XOR PTM C! ;
: WAIT 5000 0 DO LOOP ;
: T 50 0 DO BLINK WAIT LOOP ;