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:
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)?
The only model-independent code? You don't do anything with setting of speed in KnightOS? Also, have you actually verified TI-83+SE compatibility, or are you just guessing?
Not TI-83+ SE, but TI-83+, yes, a few builds ago. And I used to set the speed, but I disabled it as I tried to narrow down what was causing this bug.
EDIT: I found the problem. It was pretty stupid. You notice that the second group of code on my first post appears to be called? It is. You probably shouldn't muck about with memory while the stack needs preserving. It runs fine on all hardware now.
Again, make sure you actually test it on all four models and a bunch of different revisions of the hardware, unless you already have, in which case kudos. Was BrandonW's long discussion with you this evening the catalyst to the solution?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement