Hello,
I'm having some issues with KnightOS. As of right now, it runs fine on the TI-83+ (SE). However, on the TI-84+ (SE), it crashes. I believe this to be caused by improper USB interrupt handling. KnightOS runs without incident if interrupts are turned on, but as soon as interrupts (and multitasking) are turned on, it will crash. Here is my USB interrupt code:
Code:
However, if you don't notice anything wrong with this, it may not be the problem. Also suspect is the code that sets up the memory mappings on boot:
Code:
I'd put my money on USB interrupts, but that's just me. You are now looking at the only model-dependent code in the whole OS, so this is pretty much where the problem has to lie. Is there any hardware I may not have initialized properly, or something I may have left out that is required on the TI-84+ (SE)?
I'm having some issues with KnightOS. As of right now, it runs fine on the TI-83+ (SE). However, on the TI-84+ (SE), it crashes. I believe this to be caused by improper USB interrupt handling. KnightOS runs without incident if interrupts are turned on, but as soon as interrupts (and multitasking) are turned on, it will crash. Here is my USB interrupt code:
Code:
HandleUSBEvents:
ld a, (ModelID)
cp 2 ; Models 2 and up have USB.
jp c, ResumeInterrupt ; Leave if we don't have the hardware (also tested with NC)
in a, (55h) ; Read USB status
bit 0, a
jr z, UnknownUSBEvent
bit 2, a
jr z, USBLineInterrupt
bit 4, a
jp z, USBProtocolInterrupt
jp ResumeInterrupt
UnknownUSBEvent:
xor a
out (5Bh), a ; Unknown event, WikiTI claims you should zero port 5B to acknowledge
jp ResumeInterrupt
USBLineInterrupt:
in a, (56h)
ld c, a
cpl ; xor 0FFh
ld b, a
in a, (57h)
ld d, a
and b
out (57h), a
ld a, d
out (57h), a ; Ack the interrupt without doing anything special
jp ResumeInterrupt
USBProtocolInterrupt:
in a, (86h)
ld c, a
in a, (84h)
ld b, a
in a, (85h)
in a, (83h)
in a, (82h) ; Just ack and leave, and hope that it doesn't get angry
jp ResumeInterrupt
However, if you don't notice anything wrong with this, it may not be the problem. Also suspect is the code that sets up the memory mappings on boot:
Code:
ld a, 1 ; Set flash page 1 in bank 1.
out (6), a
in a, (2) ;get calc version
rlca ;Roll bit 7 into carry.
ld a, 41h ; Set ram page 1 in bank 2.
jr nc, LowerModel ; C vs NC?
HigherModel:
out (5),a
ld a,81h
out (7),a
jr Return
LowerModel:
out (6), a
out (7),a
Return:
ret
I'd put my money on USB interrupts, but that's just me. You are now looking at the only model-dependent code in the whole OS, so this is pretty much where the problem has to lie. Is there any hardware I may not have initialized properly, or something I may have left out that is required on the TI-84+ (SE)?