6502 Watch

Introduction

The 6502 has been around for just about 40 years, yet still powers the hearts of many electrical systems in place today, such as many microcontrollers and embedded systems. In fact, WDC still manufactures the 6502 and 65xx series chips under the 65c02 and 65cxx. I've noticed that WDC also introduced more package variants of the 6502 and 6522, such as PLCC and QFP. Another thing I noticed was the fact that these form factors of the 65c02 are almost never used. Given that the only people buying these are hobbyists, that isn't too suprizing, as they dont offer much over the standard 40 pin DIP.What they do offer, however, is small package size. I went off to try and design the smallest 6502 SBC i could, and was pleasantly suprized with the results. What I ended up with was what i think is the smallest hobbyist 6502 SBC produced. Small enough, in fact, that you could easily wear it on your wrist! I then added the neat little Nokia 5110 LCD and a cool interface, and now have what I believe to be the only 6502-driven watch in existance.

Features

Schematics & Boards

Schematics and boards were laid out using Kicad. The watch board is 3x1.5 inches in size and double sided. The board uses all SMD parts except for the PLCC socket, keyboard connector, and LCD connector.

^Not to scale^

Software

The 6502 Watch runs a few key programs. It runs G'Mon (Generic Monitor) as a main development and tinkering utility. G'Mon supports viewing memory in single and batch, depositing memory in single or batch, jumping to programs, filling blocks of memory with a pattern byte, and moving blocks of memory. The version of G'Mon used on the watch is stripped down to the basics in order to fit it on the ROM along with EhBasic. EhBasic is included as the second main utility on the ROM. It was just barely able to fit into the ROM with everything else, like there are ~ 100 bytes left. EhBasic is modified to hook into the watch's main code, the Kernel. The Kernel contains all of the init routines and hardware interface routines, aswell as all of the links needed to stitch each utility together. The last piece of software on the ROM is the Watch Menu, which allows a way to select what program to run.

LCD

A significant chunk of the kernel is dedicated to the 5110 LCD, which is communicated to through bitbanged SPI from the 6522. the WriteBYTE and Command routines exist to send either graphics data or command data to the LCD. Since the LCD is graphical only, as in no text mode, I had to write routines for writing characters to the screen. The character data is stored in a bitmap on the ROM and refrenced using two lookup tables: one for the high byte and another for the low byte, together pointing to the absolute location of the start of the input character in memory. The Write routine is called with an ascii code in the accumulator, which is then also used as the X input for the lookup tables. The write routine first writes the ascii code to a buffer of the screen in memory. It then looks up the location of the respective tile data and sets up a pointer to it. After printing 8 consecutive bytes from the pointer, it calls the CCheck routine. CCheck tracks the cursor in software and calls Scroll if the screen is full. Scroll scrolls the screen down by one line of text. Since i didn't implement any way to read from the LCD, all text is indexed using its cursor position and written to a screen buffer in memory. Scroll prints the bottom three rows of data from the buffer onto the top three rows on the LCD, then prints a row of spaces on the bottom line. The buffer is updated with the new screen data and the routine finishes. The last main LCD routine is CReturn. CReturn uses a lookup table to find the start location of the next row, and if the current row is not the bottom one, it will then increment the cursor position. If it is the last row, then it calls Scroll before finishing.

Keyboard

The keyboard is read using the 6522 VIA using the GETKey routine. GETKey multiplexes each row of the keyboard and stores the byte in memory. Then, if any bits are set (0), it refrences a lookup table to determine the ascii code of the pressed key. Much of the code is coded without loops in order to be as fast as possible. The routines to convert the set bits into an index dont use any lookup tables, but as a result the code is rather large and inefficient.

Pictures

Demo

Notes

This project is not worked on anymore, as I have moved on to other projects. Hopefully it's code can be useful for anyone else trying to use the 5110 LCD. The LCD routines are clean and efficient and should be easy to implement in any other project. The needed routines are Write, Write_NS, Command, WriteBYTE, LCDInit, LCDClear, CCheck, CCheck_NS, CReturn, Scroll, and SETCursor. Other useful routines are LCDHome and WriteBMP. The required memory variables are LCDCursor, GTmp, GTmp5, and GTmp6; also, Screen is a table 84 bytes long and must be present in RAM. The needed lookup tables are CRTbl, CTableX, and CTableY. The last thing required are Char and Char2, which are bitmaps containing all of the tile data.


To create tilesets, use the templates located in the Assets folder. In GIMP, export your bitmap as a RAW .data file using the (R, G, B) format (not R,G,B,X). Ignore the .pal file and copy the .data file to the BITConvert directory in the Project source. Run "Convert.sh XXX", where XXX is your .data file. The output file FONT.bin is the final usable bitmap.