After a bit of tinkering and struggling with the Propeller tools (yeaaargh!) Kevin was able to work up some code for enabling the dedicated switch bank and reading the state of the switches. If we can accurately detect the state of these switches, we have gone a long way toward showing that our interface concept will work.
This is a pretty nerdy post. Some things are just nerdy. Enjoy it for what it is.
Our prototype circuit is pretty simple. Here is a simplified schematic leaving out power connections. Pardon my messy schematic here, I'm learning how to use the GEDA projects gschem tool. Clearly my new sym definition for the propeller chip has a few glitches.
The propeller chip is set to drive the 1 of 8 demultiplexer, and 8 I/O pins are wired up through 1.5K resistors in serial to the D0-D7 lines on our adapter cable. The 8 lines of output from the 74LS138 are wired directly to the adapter cable patched in where we removed the same chip from the CPU board.
The serial resistors are used to drop the voltage coming back from the CPU board into an acceptable range for the propeller chip. The CPU board circuitry is designed to drive 5V signals whereas the propeller chip is rated at a 3.3V max for logic high. I really should be using 10K resistors here, but I had a string of 1.5K's handy and the resulting voltage is a bit under 4Vs. According to the folks at Parallax, this will be ok for short tests as the chip has internal regulation to manage overdriven input, but I'm at risk of overheating or destroying the safety latch. In other words, use 10K resistors, I'll be switching mine out shortly.
While I was soldering cables, desoldering and pulling chips, and wiring up the protoboard with the wrong resistors, Kevin has been working up some code for the propeller chip to do three key tasks:
Keep the CPU watchdog system from pulling the board into reset
Enable the dedicated switch inputs on the data bus
read the state of the switches
The CPU board is designed with some circuitry to protect itself in the event that certain systems fail. Mainly this pulls a set of key chips into reset, preventing random and potentially damaging signals from driving the system. This is accomplished with a watchdog timer chip at U218 (lower right corner of page 2 of the schematic). This is a DS1232 chip which simply has a configurable threshold time before it pulls the value of two reset lines, one for the IO system and one for the CPU board. To keep the reset from triggering the chip must be pinged within the threshold time by stimulating a strobe input pin. Yes the datasheet actually says stimulated.
If you are wondering what I'm talking about with "pull chips into reset", it is really not complicated. All that is happening is that some of the chips have enable pins that are generally always held in the enabled state unless the system goes into reset, in which case the chips enable pins are set to disable. You can trace the RESET line from U218 and see that it hits quite a few other components.
Looking at U218, the strobe input pin #7, we see it is driven using the BSEL signal. You should recognize this from our earlier exercises as the Bank Select signal (one of the 1 of 8 from the address decoder). The watchdog is set to reset after 250ms unless triggered. Even though we have no use for the BSEL signal anymore, I think it is a very good idea to keep the reset circuit in place, so part of our code simply needs to toggle the BSEL signal as part of the main execution loop. If it turns out to be a complete waste of cpu cycles toggling this signal, we can always bridge another signal to the watchdog. This works for now.
Enabling the dedicated switch inputs is achieved by enabling the 74LS138 and setting the three input pins to the proper value to enable the SWLO pin. Once enabled, checking the values of the D5 D6 and D7 data lines will let us know if any of the three hooked up dedicated switches are being pressed. These switch inputs are hooked up to the reset and volume switches located inside the coin door. The lines are low enable, meaning that they will read at +5V until the button is pressed, then read at 0. The other 5 dedicated switches are currently not used.
That's it for the code for now, time to put everything back in the machine and see what happens.