KIM Monitor KIM clone

KIM monitor as modified for the Corsham Tech KIM Clone board.

Notable changes:
* Removal of the code to save/load from cassette tape.
* Lunar Lander (First Book of KIM) added.
* Famer Brown (First Book of KIM) added.
* New X command from TTY to enter the Corsham Technologies xKIM extended monitor.

See also the Corsham github page.

Download the KIM Monitor repository copy here.

Note that you can use the standard KIM ROMs also, the KIM Clone is a KIM-1.

Extended KIM Monitor

xKIM

xKIM is an extended monitor for KIM computer systems. Commonly used in Corsham Technologies KIM-1 add-on boards.
It is a 6502 based monitor which has basic tools as well as some additional commands for working
with the Corsham Tech SD Card system.

Features
* Pure 6502 code.
* Many subroutines available for external programs to use.
* Can auto-run Intel hex files upon loading.
* Can be placed in read-only memory.
* Has all low-level subroutines for talking to the SD Card.
* New commands can be added at run-time to the command handler.

Command Summary (not a complete list)
* Examine/edit memory.
* Jump to code.
* Load Intel hex file from console or SD card.
* Directory of SD card.
* Get clock from RTC.
* Memory test.
* Branch offset calculator, also within memory editor.
* Type SD file.
* Save memory to SD file.

Downloads
xKIM-master 2021
xKIM older versions

xKIM Manual 1.6

Parallel port adapter

A small project to convert the connector on the KIM I/O board to a Parallel Port adapter (2021).


KIM-1 Software

Bob Applegate published quite a lot of 6502 code.

Basic interpreters for the 6502

Getting enough memory and bringing up a BASIC interpreter were early goals of many personal computer users back in the 1970s.  While Dr Dobb’s Journal was printing a new small BASIC interpreter for the 8080 almost every month, 6502 users were left out in the cold.  Fortunately, Tom Pittman produced a Tiny BASIC that he charged $5 for.  Microsoft also ported their full floating point BASIC but it was not cheap.

Nowadays the source code for these and other BASIC interpreters are freely available on the internet but usually require the user to jump through some hoops to use them. Ie, setting up a build environment. To make things a bit easier, I’ve put binaries and some sources on this page. These are all quite runnable on a KIM-1 with extra memory. There are no interpreted languages that I am aware of that will run in the 1K KIM-1 although Tiny PILOT from Compute magazine can run in 2K, that’s what I used.

Tom Pittman’s Tiny BASIC

Tom distributed a very small BASIC that needed about 3K to run, and was available on paper tape for $5!!! He has quite a bit about it at:

http://www.ittybittycomputers.com/IttyBitty/TinyBasic/

On there is a KIM-1 version that annoys me a bit. Tom and I worked about 10 years ago to disassemble and produce a really good source code package with a lot of my reverse engineering and his comments about portions of the code he could remember details of. For some reason he put up a poorly commented version Here is the source code, listing, and binary to my disassembly which includes a lot of comments and notes from Tom:

Tiny Basic by Corsham

A ready-to-run binary which loads at $0200 and should have RAM up to $13FF

tinybasic.hex

(see also the Tiny Basic page)

Microsoft 8K BASIC

First, here are complete instructions for building your own version Install the CC65 package, then run the make.sh command, then look at the file tmp/kb9.bin, You’ll need to convert that raw binary image to a file suitable for downloading to the KIM.
Or just use my binary. All of these needs at least 12K of RAM starting at $2000.

(see also the Microsoft Basic page)

Create your own Version of Microsoft BASIC for 6502” — pagetable.com

Binaries

Here is a file suitable for downloading onto a KIM-1. It loads at $2000 but to run it you’ll need to start at $4065. Use the L command in KIM-1’s monitor, then upload the file.  I strongly suggest that you change your terminal emulator so it adds a 200 ms pause at the end of each line.  Once it loads, run it by going to 4065 and running it at $4065 G; To see the easter egg, answer “A” when it asks for memory size.

Original KIM-1 Microsoft BASIC: kb9

This is still experimental but I have a version which uses functions in the xKIM monitor (present on the KIM Clone or on the 60K RAM/EPROM board) to save/load from the SD Card System. It also has a DIR command. This is an Intel HEX file and must be loaded from the xKIM “L” command:

xkim

This loads and runs at $2000.

Bob’s Tiny BASIC

All the early issues of Dr Dobb’s Journal discussed using using an intermediate language (IL) to write a general interpreter, then writing a BASIC interpreter using the IL language.  Nobody used this except for Tom Pittman. I liked the idea and about five years ago wrote my own BASIC using that approach. It is buggy, but the sources are on github so anyone can take them, hopefully debug things, and put fixes back in place. My version also has commands to save/load programs to/from a Corsham Technologies’ SD Card System.

Source code:

Github Corsham

And a binary version that can be run starting at address 0200:

mytb.hex

Versions:
2019 archive
2021 archive

Bob’s_Tiny BASIC

SD Card Shield

When we began building the first of our SS-50 series of cards, the most common request was for a mass storage option. Those old disk controllers are hard to find on the surplus market and the old disk drives are getting harder to maintain. While we like vintage equipment, sometimes it’s worth using some modern technology to do updates.

Enter our SD Card System.
This is a two board system that provides a very inexpensive, flexible, and long-lasting storage option for our KIM Clone , SS-50 based designs, or almost any third party system.

The main board is our SD Shield. It plugs into an Arduino Mega and provides for insertion of a micro SD card, and also includes a DS3231 based real time clock (RTC). The Arduino does the hard work of providing an interface between the host processor (6502, 6800, 6809, etc) and the SD card and RTC. It connects to the host via a ribbon cable.

The board also contains three LEDs used for status, a RESET switch, a four position DIP switch, a DS3231 RTC, backup battery, and it maintains the Arduino Mega headers so additional shields can be placed on top. Since the source code is available you can add additional drivers for whatever shields you add. Want to add an LCD shield that displays which files are mounted? Just plug in the shield and modify the user interface class in the source code. Only one of the DIP switches has a defined purpose, so the rest are free for you to add your own logic.

The protocol between the host and the SD Card System is completely defined in The Remote Disk Protocol Guide.

In order to use this card on an SS-50 based system, you will also need a parallel card such as ours.



SD Card System 2015
SD Card System 2017
SD Card System 2021
The Remote Disk Protocol Guide August 2015 V0.1
The Remote Disk Protocol Guide April 2017 V1.1

Downloads
Drivers for 6502, 6800 and 6089 Flex, Arduino Mega Firmware, SD Images Flex, older versions also
Firmware 2021
Test program for SD Shield
Clock utilities set time and date from KIM-1
Reproduction and uptodate SD Shield by Eduardo Casino (Github copy)


The schematic above is the only version posted. It is not the latest schematic used by Bob (see below). Eduardo Casino (see the download above) reverse engineered the SD Shield and produced an uptodate version 9.

April 5, 2021 New Version of SD Card Shield

This is another board done entirely with KiCad and rolls in a few changes from the previous boards. It is completely compatible with the rev 8 boards, which were compatible with rev 7, which were compatible with… etc, etc, etc.There is no new revision of Arduino code for this board.

No new features but a few changes:

  • The CR1220 battery has been replaced with a much more common CR2032 to keep the RTC (Real Time Clock) chip alive.  I did extension market research (ie, I emailed all my nieces and nephews) and found they all had 2032 batteries at home, while none of them had 1220s.My family is used to getting odd emails from Uncle Bob.  The local hardware store was surprised  when I asked about CR1220s, so going to a more common battery makes sense.
  • A different micro SD socket. The old one was push-in, pull-out, but this one is pop-in, pop-out.  It also has alignment pins on the bottom making it much easier to get seated exactly in the right spot before soldering. The solder connections are at the back of the socket, not in the front like the old board.  So far every surface mount solder job with the new socket has been perfect the first time, whereas the old sockets needing to be touched-up about 15% of the time.
  • The old 5-pin header for an external RTC board has been removed, allowing the LEDs to be aligned in a row.  With the RTC on-board there was little reason to keep the header.
  • Added a clearly labeled 4-pin area for adding external I2C devices.
  • For those buying the bare board, the LED colors are labeled on the silk screen. BTW, the “bare board” has the DS3231 RTC and the microSD socket already soldered.

The rev 9k1A will eventually be changed to just rev 9, as there is no need to keep KiCad revisions uniquely identified.

March 21, 2018 What’s On the Bench

Sometimes it’s nice to just enhance an existing product, especially when the supply of blank boards starts running low and more need to be ordered.  I’m running low on the SD shields so it was a good time to make some improvements. This is a prototype:

The changes from the Rev 4 boards:

  • A DS3231 RTC and backup battery are now on-board instead of having the plug-in RTC.; Too many of those plug-in boards had batteries that died within a year or two, so I decided to just put the chip directly on the board and have a battery connector.  It takes a very common LR44 battery which can be replaced easily when it fails.
  • DIP switches are clearly labeled as to which is which, and which direction is on and off.
  • A pull-down resistor is temporarily added here to fix a problem where the green and red LEDs don’t work right until the host computer initializes the interface to the SD shield. A pin was left floating and confused the software into thinking the host was sending a byte when it wasn’t.
  • Two I2C pull-up resistors were added but do not seem to be necessary.

There will eventually be a Rev 6 with the new pull-down resistor and maybe the two pull-ups removed, but I’ll use the current Rev 5 boards and manually add the pull-down for now.

The RTC is completely software compatible with the current boards so any version of our Arduino code will work with it.

KIM Clone Motherboard

KIM Clone Motherboard

KIM Clone Motherboard User Manual
KIM Clone Motherboard schematic

KIM Clone I/O board

KIM Clone I/O board

KIM Clone I/O Board Manual

KIM Clone I/O board Rev 2, 1 of 3


KIM Clone I/O board Rev 2, 2 of 3


KIM Clone I/O board Rev 2, 3 of 3

KIM Clone I/O board Rev 3, 1 of 3


KIM Clone I/O board Rev 3, 2 of 3


KIM Clone I/O board Rev 3, 3 of 3

Automated tester

What I Do with a KIM Clone>

The KIM Clone and the 6530 replacement boards both use a 6532 to replace the non-existent 6530-2 and 6530-3 chips that were used on the original KIM-1.  These chips haven’t been made by any reputable source in decades, so everyone ends up buying from unknown sources on the internet, usually floor sweepings from China.  It takes about 10 minutes to thoroughly test a single chip, so I was looking for a fully automated way to do the testing for me.

Given the expansion bus on the KIM Clone, I designed a really simple little board that takes 256 bytes of otherwise unused memory and maps in a known good 68B21 PIA, a 68B21 under test and a 6532 under test.  Add a bit of clever software and all pieces of either the 6832 or 6532 can be tested in a matter of seconds!

This is revision 1 of the board:

It uses one chip to decode the address to see if the address is for this board or not, then another chip to decode which chip on the board is being addressed.  As you can see, a third chip was tacked on once it was obvious I had missed something.  The lowest chip is the known good 68B21.  The empty socket is for a 6821 being tested, and the top socket is a 6532 being tested.  The two test sockets were supposed to be ZIF (Zero Insertion Force) sockets but I didn’t make the holes large enough and was forced to use standard 40 pin IC sockets.  Both the missing chip and the wrong size holes have been fixed on the rev 2 boards.

There is a separate power switch for the board so I can turn it off and swap chips for testing.

The code is very simple and is just over 1K in size.  It tests the RAM and I/O ports fairly well, but the timer section is a bit weak and needs more work.  I’m a software person by profession, so once the hardware is solid I can spend an infinite amount of time putzing around optimizing the software.

Let me talk about adding I/O devices that don’t need much address space.  On the KIM-1, the space from 1400-17FF is grouped into the K0 block but only 17xx are used, leaving 1400-16FF open for use.  To decode that range into four blocks of 256 bytes is easy using a single chip and a few signals from the KIM Clone expansion bus:

Everyone has a 74LS138 in their parts collection, so just connect a few signals from the expansion bus and use one of the three signals from the 138 to decode which block you want to use.  Use the A0-A7 address lines to decode into smaller pieces.

 

Using KIM Clone I/O Pins

Using KIM Clone I/O Pins

Like the original KIM-1, there are 16 I/O lines on the KIM Clone that can be used for your own projects. They are brought to the connector labeled “SD SYSTEM” along the top edge of the board and were meant to plug into one of our SD Card Systems for program storage. However, they are general purpose I/O lines which can be freely used for other things if the SD system is not used.

This is a portion of the schematic showing which pins on the 6532 are connected to which pins on the connector:

Don’t worry about the signal names associated with the various lines, they are the names of those signals when an SD Card System is attached.

As you can see, there are 16 IO lines, 2 ground lines, and 2 lines with +7.5… if you want to draw power from this connector for TTL/CMOS circuits then you need to add your own +5 volt regulator! D2 prevents back-feeding power from the connector back into the KIM Clone.

On the circuit board, pins 1 and 2 are labeled but are covered by the connector, so here is a reference:


All of the odd numbered pins are on the “bottom” row while even numbered pins are on the top. Ie, the top row has pins 2, 4, 6, etc, while the bottom row has 1, 3, 5, etc. Displaying the circuit board traces on the bottom layer of the board you can clearly see the ground and power lines connected to the pins on the far right:

The datasheet for the 6532 RIOT chip is readily available on the internet, but here is an easy one:

http://archive.6502.org/datasheets/mos_6532_riot.pdf

To program the chip you basically need to set the direction of each pin of the I/O port of interest (Port A or Port B), then set the data or read the data. The base address of the chip is 1700 (hex). There are four registers:

Address Use
1700 Data register A
1701 Data direction register A. Setting a bit to 1 makes it an output bit, 0 makes it an input.
1702 Data register B
1703 Data direction register B. Setting a bit to 1 makes it an output bit, 0 makes it an input.

An Example

I needed to test experimental address decoder logic and found it was easier to just plug it into the I/O ports and write some code on the KIM Clone to simulate the addresses and display what the decoder logic did:

Port A simulates address lines A11-A16 and port B has the three decoder outputs (/RAM, /IO, /EEPROM). A small program simulates all possible values of the five address bits, displays the address, reads the decoder inputs and then displays which are active. In about an hour I was able to fix one minor bug in the decoder design and perform a full unit test on how it works. Certainly not a fancy example of using I/O ports, but sometimes it far faster to build a small circuit and use software to test it rather than building a lot of hardware and manually debugging it all.