borb/amigahid

usb library sometimes causes avr to reset

Opened this issue · 4 comments

borb commented

on occasion, what might be a bug in the uhs library causes the avr to reset. when this occurs, the amiga is reset because the reset line is asserted (or maybe AMIGA_INITPOWER & AMIGA_TERMPOWER). stop this from resetting the amiga; a keyboard glitch should not reset the machine.

it could be that setting up the active high/active low status of the reset pin is causing the reset. don't init the registers to zero, set directly to direction and see if that solves things.

shame that simulating an error in a fairly reliable library isn't actually that simple. let's try to fix anyway.

borb commented

The problem is less the USB library and more the fact that the Amiga 500 reset line is active low, thus high is considered the normal state. When the Arduino resets, the ports are also reset so for a moment until the line is brought high again, the low state is enough to trigger an Amiga reset.

If the interface is modified to have a pullup, then we'll lose reset but the line will be held high and thus will be kept active, at the expense of losing reset. The A1000 & A2000 keyboards reset by holding KCLK low for at least 500ms, but it's likely that mechanism doesn't work on the A500 owing to the reset line. Could be worth trying though.

borb commented

Disabling the wdt is likely a bad idea since a crash can mean that the keyboard becomes completely useless until a power cycle occurs.

borb commented

Could use a simple transistor circuit NOT or a 555; transistor would be easier: arduino reset line to base through resistor, power on base sinks collector's input from vcc to ground (pulling low), so base low closes stops emitter sinking to ground thus letting emitter output feed the Amiga reset line.

                         ______ Vcc 5V
                            \
                            /
                        r2  \
                            /
                          __|___ to amiga reset
                r1      |/
 arduino krst -\/\/\/---|
                        |\>_
                            |
                            |
                          -----
                           ---
                            -   ground

r1 & r2 should be calculated to avoid >5V going through reset (though open base means collector to ground, so arduino krst low would mean empty base thus no additional voltage, plus that's on emitter not collector).

borb commented

(just occurred to me that I have a few hundred 74hc04d hex inverters on hand, will test when I get a chance)