[TI ASM] Interrupt problems.. (Ti-84)

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

[TI ASM] Interrupt problems.. (Ti-84)

Post 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]
Last edited by cjgone on Wed 29 Nov, 2006 10:00 pm, edited 3 times in total.
User avatar
NanoWar
Extreme Poster
Posts: 365
Joined: Fri 17 Dec, 2004 6:39 pm
Location: #$&"%§!
Contact:

Post 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
;
Revolution Software
Kalimero
Regular Member
Posts: 130
Joined: Fri 17 Dec, 2004 1:47 pm

Post 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:

Code: Select all

	ex  af,af'
	exx
	reti
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
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Post by cjgone »

Thanks. I read somethig about sending $0Ah to Port 3. Is it 0Ah or 0Bh?
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

That would leave you with the on key not generating an interrupt when pressed. It has little significance normally.
Kalimero
Regular Member
Posts: 130
Joined: Fri 17 Dec, 2004 1:47 pm

Post 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).
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Long time response...

Post 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?
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

the one in "Learn TI-83 Plus Assembly In 28 Days" is correct
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post 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).
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post 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 ;)
User avatar
KermMartian
Calc Wizard
Posts: 549
Joined: Tue 05 Jul, 2005 11:28 pm
Contact:

Post by KermMartian »

I always wondered if that info in asm28d was correct or not... that could explain some Cn2 bugginess...
Image Image Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post 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)
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Z80 Manual

Post by cjgone »

Thanks.. That Z80 manual will hopefully help my understanding of the processor.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: Z80 Manual

Post 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.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

ddds

Post 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?
Last edited by cjgone on Sun 10 Dec, 2006 10:16 am, edited 1 time in total.
Post Reply