Skip to main content
Topic: KimCard - KIM-1 6502 Single Board Computer Emulator (Read 30158 times) previous topic - next topic

KimCard - KIM-1 6502 Single Board Computer Emulator

Today I soldered up and wrote a quick dummy test on my KimCard.  The KimCard is to be a credit card sized emulator of the KIM-1 single board computer back from the mid-seventies. http://en.wikipedia.org/wiki/KIM-1

[attachment=2]
It has a whopping 1 KB of RAM and is running at 1 MHz on a 6502.  Software entry is done either on the hexadecimal keypad with six 7-digit displays as the output or via a teletype terminal.

My emulator will emulate the 6502 and some of the functionality of the ROM/RAM/IO/TIMER support chips on the board using a ATXMEGA32D4.  Possibly also the Teletype interface will be emulated over the USB connector as a standard CDC interface.

To Save/Load the code  a cassette tape interface or punched paper tape on the Teletype was used.  I'll probably use a serial EEPROM as storage for a few images of the 1K RAM memory space.

[attachment=1]
When I first connected the micro USB cable to power it my 3.6 volt vreg started smoking. That is usually not a good sign....  It turned out that the micro usb connector I had home had the connectors reversed compared to the footprint (Sparkfun)  I used in the design. So I basically fed the reg with -5 volt instead of +5 volt - no wonder that it didn't like it.

So I scraped off some soldermask and soldered a mini usb and just greenwired (or in this case yellowwired ^_^) the power lead into the board  (The USB data wires will be dealt with later) , replaced the vreg and crossed my fingers.  And whoo!  The power led came on and I could connect to the CPU with the PDI programming/debugging interface.

A few lines of code later and I could test that the rest of the hardware was in reasonable shape.  The green power led is far too bright and the seven segments are too dim. But that is to be expected.

I haven't attached the lipo battery or the charger for it yet.  And since I'm not using the USB comms yet I haven't bothered to get the crystal in place either - for the time being the 32 MHz internal oscillator is fine.

So far I'm rather happy and will now start to get the 6502 emulator part of the code in shape - but that won't happen until after my entry of the 7400 competition is in.

[attachment=0]

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #1
Yellow wire completes the design :)

Nice work, this is one heck of a project. I like uC processor emulators. Good stuff.
Got a question? Please ask in the forum for the fastest answers.

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #2
Nice work. We've been discussion doing a 6502 (or other CPU, pick your favorite 8-bitter) board at our local Maker Space but this looks nice.
Tony

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #3
Thanks,

It's fun to play with old retro stuff.  The KIM-1 was actually my first computer back in 1977 when I was 12 years old.  After the KIM-1 I've got a AIM-65 followed by an Apple ][ so you could say that I was born and raised on 6502 processors. 

I still, after all these years, remembers a dozen or two of the hex codes for the common 6502 op-codes.  I did a lot of hand-assembly back in the days so I guess it stuck in my brain :)

But of course I did use both the Z80 and the 8085 in projects in the mid-80'ies.

I remember wanting a COSMAC 1802 during my KIM-1 years since the Cosmac had TV-out....

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #4
Ah crap....  The art of not reading the erratas of the datasheets strikes back!

I've connected the I2C eeprom to PE0/PE1 on the ATXMEGA32 beause according to the datasheet that is the secondary TWI/I2C port. But after struggling two hours trying to get it work I took a look at the SDA/SLC lines as saw that they were completely dead. So I read the datasheet more carefully and realized that the errata says the following:

Non available functions and options
The below function and options are not available. Writing to any registers or fuse to try and
enable or configure these functions or options will have no effect, and will be as writing to a
reserved address location.
•TWIE, the TWI module on PORTE
Problem fix/Workaround
None.

Ok, it seems like I have to bitbang the I2C for the time being and then move the i2c to the primary on portc in the next revision of the board. Problem is that those ports are already in use..

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #5
Be nice if they put those warnings in the datasheet too :) If datasheets were wikis I'd annotate them like crazy.
Got a question? Please ask in the forum for the fastest answers.

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #6
I also find some erratas quite "creative".  I once read a datasheet about some low power MCU stating to use at most some specific current value when powered down, only to find in the errata then an entry like "Power down current exceeds value from datasheet".

I mean, this is rediculous.  This way you can advertise anything in the datasheet and then say its an erratum if you don't meet these characteristics.

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #7
[quote author="ian"]Be nice if they put those warnings in the datasheet too :) If datasheets were wikis I'd annotate them like crazy.[/quote]

On my android pad I can highlight, underline, strikeout parts of the pdf's .. I can add text on the margins, graphical stuff, can circle stuff .. all mobile devices I used to use since I-Mate in 2002 had this possibility ... Donno how is it with adobe reader on winblows but Document Viewer on linux afaik do not support that (haven't tried adobe reader on linux for a long time but last time I did it was not supporting annotation :( )

Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #8
Sure, sure, I do too, but we all make the same notes. I wish I could download a collaborative version with your notes already written in, and to share mind back for tohers.
Got a question? Please ask in the forum for the fastest answers.


Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #10
I've been working on the 6502 emulator firmware this weekend and have reached the point where I can (almost) run two of my favorite games from the seventies on it.

But the Lunar Lander game requires emulation of  add/sub with the Decimal mode-flag set I.E. packed BCD additions instead of a  standard binary addition.  If you add 1 to (hex) 0x19 you normally get 0x1A but in decimal mode you get 0x20. And 0x99 + 1 is then of course 0x00.  And the same for the subtract instructions.  And it need to support Carry in/out as well.

Sound easy enough, but doing this is AVR assembly turned out to be a small nightmare.  I'm glad that the XMEGA ticks on in 32 MHz giving me close to 32 MIPS to play with, but even then I can't emulate an 8 bit decimal add in full 6502 1MHz speed :-(

Luckily the decimal mode add/sub's aren't used that much so in a normal program and on average most programs currently run 10% faster on my emulator than the original 6502 KIM-1.


Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #12
Thanks.  Nothing as fancy as the PIC's daw-instruction, and certainly nothing as advanced as the 6502 D-flag in the status register where when set the adc/sbc instructions operate fully in packed bcd mode.

But looking at the daw-less PIC code for bcd math I see that I probably can shave off an instruction or two in my code....

I'm not too sure in what usage cases anyone actually would use bcd math - it feels a bit like having a 3'rd leg on a chicken - completely useless. (unless you want to eat it ^_^  )


Re: KimCard - KIM-1 6502 Single Board Computer Emulator

Reply #14
Hello.

I love to get my hands on such a KimCard!! Where and how can I get one?

Excellent work!

Many thanks, Peter