Page 1 of 2
[TI ASM] Interrupt problems.. (Ti-84)
Posted: Sun 11 Jun, 2006 7:41 am
by cjgone
This has already been fixed (Sun Jun 11, 2006 ):
I just learned how to make an interrupt for the Ti-84\83 series. My code, shown below is supposed to make a flickery grayscale line (if you can call it that) on the first line of the screen ($9340\plotsscreen). All it does though, is show a black line and it just sits there for about a minute. Then it turns white and it clears my ram. Can anyone explain? Thanks.
Code: Select all
.NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#define end .end
#include "ti83plus.inc"
.LIST
.org 9D93h
.db $BB,$6D
di
ld hl,$9900
ld de,$9901
ld bc,256
ld (hl),$9a
ldir
ld hl,interrupt_start
ld de,$9a9a
ld bc,interrupt_end-interrupt_start
ldir
ld a,$99
ld i,a
im 2
ei
Loop:
jp Loop
interrupt_start:
exx
ex af,af'
ld a,%11111111
ld ($9340),a
B_CALL(_Grbufcpy)
ld a,%00000000
ld ($9340),a
B_CALL(_Grbufcpy)
ex af,af'
exx
reti
interrupt_end:
.end
end
[/list]
Posted: Sun 11 Jun, 2006 8:15 am
by NanoWar
First I would put a key handler in your loop for better exiting.
Maybe the two 'B_CALL(_Grbufcpy)" are too close or don't work.
Code: Select all
;
Loop:
ld a,0ffh ;keyboard reset
out (1),a
ld a,0bfh ;Group7
out (1),a
in a,(1)
cp 191 ;kMode
jr nz,Loop
interrupt_start:
exx
ex af,af'
ld hl,$9340 ;gbuf
ld a,(hl)
xor a ;inverse byte
ld (hl),a
call ionfastcopy
ex af,af'
exx
reti
interrupt_end:
;ionfastcopy by Joe Wingbermuehle (ION)
ionfastcopy:
di
ld a,$80 ; 7
out ($10),a ; 11
ld hl,gbuf-12-(-(12*64)+1) ; 10
ld a,$20 ; 7
ld c,a ; 4
inc hl ; 6 waste
dec hl ; 6 waste
fastCopyAgain:
ld b,64 ; 7
inc c ; 4
ld de,-(12*64)+1 ; 10
out ($10),a ; 11
add hl,de ; 11
ld de,10 ; 10
fastCopyLoop:
add hl,de ; 11
inc hl ; 6 waste
inc hl ; 6 waste
inc de ; 6
ld a,(hl) ; 7
out ($11),a ; 11
dec de ; 6
djnz fastCopyLoop ; 13/8
ld a,c ; 4
cp $2B+1 ; 7
jr nz,fastCopyAgain ; 10/1
ret ; 10
;
Posted: Sun 11 Jun, 2006 10:10 am
by Kalimero
When an interrupt is accepted, interrupts are disabled so new interrupt requests won't mess up the current one. I wouldn't be surprised if _GrBufCpy enabled interrupts again causing all kinds of problems in your case. Using the fastcopy routine as NanoWar showed should solve that.
You should however also replace the end of your interrupt routine:
Use this instead:
Code: Select all
ld a,08h ; clear interrupt lines
out (3),a
ld a,0Bh ; set interrupt mask
out (3),a
ex af,af'
exx
ei ; enable interrupts again
ret
Posted: Sun 11 Jun, 2006 6:57 pm
by cjgone
Thanks. I read somethig about sending $0Ah to Port 3. Is it 0Ah or 0Bh?
Posted: Sun 11 Jun, 2006 7:10 pm
by CoBB
That would leave you with the on key not generating an interrupt when pressed. It has little significance normally.
Posted: Sun 11 Jun, 2006 7:14 pm
by Kalimero
Doesn't matter in your case. Bit 0 says whether pressing the on-key generates an interrupt. So with 0Bh you will get an interrupt request when the user presses the on-key and with 0Ah you won't. Bit 1 indicates whether the timer generates interrupt requests. So if you use 09h instead of 0Bh, the lcd will only update each time you press the on-key (perhaps interesting for debugging).
Long time response...
Posted: Tue 28 Nov, 2006 4:23 am
by cjgone
Thanks for all the help... I'm pretty sure that from some tests, that if you reset the bit so that timer Interrupts are ignored, your calculator will crash..
I just learned how to write directly to the LCD driver using port $10 and $11.. But, I'm not sure how the calculator will react when I disable interrupts.. From the Fastcopy routine that someone was nice enough to display above, it shows that you jump from the ISR then disable interrupts.. Can you disable interrupts in the ISR then write to port $10\$11? and do you have to enable interrupts when your done(consequences of doing so and not)?
Oh, and TSR's... Not sure what to say about these.. I know that you have to jump to $0038 or $003A..but i'm not sure.. Does anyone have the template, or is the one "Learn TI-83 Plus Assembly In 28 Days" correct?
Posted: Tue 28 Nov, 2006 12:26 pm
by King Harold
the one in "Learn TI-83 Plus Assembly In 28 Days" is correct
Posted: Tue 28 Nov, 2006 12:43 pm
by benryves
King Harold wrote:the one in "Learn TI-83 Plus Assembly In 28 Days" is correct
Ignore what it says about not needing a 257-byte table, though. That's incorrect. You need the full table.
As recommended, try not to use ROM calls as they will modify interrupts.
To get a better understanding of the internal mechanics of Z80 interrupts, I'd recommend looking at the relevant section in the
Z80 Family CPU User Manual (pages 42-46).
Posted: Tue 28 Nov, 2006 1:24 pm
by King Harold
benryves wrote:Ignore what it says about not needing a 257-byte table, though. That's incorrect.
True, but the program sets up the table anyway, and he asked for the template
Posted: Tue 28 Nov, 2006 5:17 pm
by KermMartian
I always wondered if that info in asm28d was correct or not... that could explain some Cn2 bugginess...
Posted: Tue 28 Nov, 2006 6:39 pm
by King Harold
When I tested it on PindurTI it seemed to work fine, I haven't tried it on hardware though (the thing from asm28d, not Cn2)
Z80 Manual
Posted: Wed 29 Nov, 2006 9:55 pm
by cjgone
Thanks.. That Z80 manual will hopefully help my understanding of the processor.
Re: Z80 Manual
Posted: Thu 30 Nov, 2006 11:46 am
by benryves
cjgone wrote:Thanks.. That Z80 manual will hopefully help my understanding of the processor.
Bear in mind that those jokers at ZiLOG like to keep you on your toes with incorrectly defined instructions, or helpful diagrams that
have the arrow pointing the wrong way. The descriptive stuff is usually pretty good though.
ddds
Posted: Sat 09 Dec, 2006 8:54 am
by cjgone
Okay, I was playing around with the Tsr's.. It seems that turning off the calculator, accessing the apps menu or opening the programs menu will kill the isr... Does that mean that I have to implement my own turn offs? (turn of the lcd with port $10, display my own program menu..etc) Oh, and when I attempted to get a keypress using port 1, I can do the stuff I want, but it also triggers what ever that key was supposed to do.. I tried clearing port 1 and disabling interrupts as I read from port 1, but it didn't work..Suggestions?