Evie Beer: Episode 7 – It’s A Stick-Up


The Other End
Now that RetroChallenge is in the closing week, it is time to take a look at the *other* end of my breakout-board:
20150726_154821
That thar be a retro “Gameport” socket. I guess that gives a good indication of the next piece of hardware that I am attempting to interface to the 68hc11 SBC…
stickappears
Yes, I’m afraid so – an old-style 1980s PC analogue joystick.

Button Down
First job was the “fire” buttons. On this kind of joystick, the buttons are wired as simple “direct-short-to-ground” SPST. So there need to be external pull-up resistors on the breakout board for the buttons.button_schematicI had originally used 10M pull-ups, thinking that would minimise the “idle” current-flow, but that turned out to be a bad idea.

Initially, when reading the PORTC pins on the 68hc11, I was getting alternative correct values then zero, tick-tock tick-tock. Even with a 1-second delay between each read. What on Earth was going on? After spending quite a while double- and triple-checking the wiring on the breakout board (it was correct, if messy, and no unintentional breaks or shorts), and wading through the copious Motorola 68hc11 technical manuals, there still didn’t seem to be any logical explanation.

Eventually, on a hunch, I figured that there was interference between the pin-buffers on PORTC, and the only plausible explanation was that those pull-up resistors were too high-impedance (too weak a pull-up effect). Although I wasn’t sure, I eventually bit the bullet and replaced the 10M pull-ups with 10K ones: a quick calculation indicated that the idle voltage would still be high enough to read as a valid high level on the MCU pins…

Desoldering partially-obscured resistors and patch-wires is one heck of a job to tackle with a cheap hand-iron, it took *ages* and plenty of sweat, but eventually I got there at the cost of an even more messy-looking breakout-board.
20150726_154809

Button-Up
With the stronger pull-ups, the buttons now read reliably! The minimal program to read the button-states, and then display the results on the LEDs is:

include(board.def)
include(hc11e.def)
include(buffalo.def)
include(lib.def)

        ORG     HIRAM
; X points to control-register block
sysinit: ldx    #CSREGS

; to avoid floating CMOS-input (near-short to ground),
; configure PORTC for *output*, except those pins that
; we have pull-ups on: C4-C7 for buttons 1-4
        ldaa    #$0f
        staa    DDRC,X

; continuously read buttons and display
main:   ldaa    PORTC,X ; read raw button state
        lsra            ; shift high-nibble to low-nibble
        lsra
        lsra
        lsra
        eora    #$ff    ; invert bits to get 1=on 0=off
        staa    PORTB,X ; show button-state on the LEDs

        bra     main    ; repeat until bored

Those “include” statements pull in static definitions for the EVBU, the MC68HC11E-series MCUs, the BUFFALO monitor (which isn’t used by this program) and my EEPROM-resident library routines (which also aren’t needed here). Let’s see whether it works… check the Button Show video. To please those readers disappointed by the previous video, this one does feature 1970s Wonder Woman in the background audio.

Note that this particular joystick has a hardware “auto-repeat-mode” switch, and both one-shot and auto-repeat operation show nice and clearly.

Of course, the buttons are not debounced in any way, so there may be more programming work to do, but due to the slow semi-synchronous final application I have in mind for this circuit, I believe that debouncing may be completely unnecessary! I know, that seems crazy, but… we will see how that works out in a later episode.

Fingers Crossed!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s