A Simple Guide To Bit Banged I2C On The 6502

We covered [Anders Nielsen]’s 65duino project a short while ago, and now he’s back with an update video showing some more details of bit-banging I2C using plain old 6502 assembly language.

Obviously, with such a simple system, there is no dedicated I2C interface hardware, so the programmer must take care of all the details of the I2C protocol in software, bit-banging it out to the peripheral and reading back the response one bit at a time.

The first detail to concern us will be the I2C addresses of the devices being connected to the bus and how low-level bit manipulation is used to turn the 7-bit I2C address into the byte being bit-banged. As [Anders] shows, setting a bit is simply a logical-OR operation, and resetting a bit is a simple logical-AND operation using the inversion (or one’s complement) bit to reset to form a bitmask. As many will already know, this process is necessary to code for a read or a write I2C operation. A further detail is that I2C uses an open-collector connection scheme, which means that no device on the bus may drive the bus to logical high; instead, they must release the drive by going to the high impedance state, and an external pull-up resistor will pull the bus high. The 6532 RIOT chip (used for I/O on the 65unio) does not have tristate control but instead uses a data direction register (DDR) to allow a pin to be an input. This will do the job just fine, albeit with slightly odd-looking code, until you know what’s going on.

From there, it’s a straightforward matter to write subroutines that generate the I2C start, stop, and NACK conditions that are required to write to the SSD1306-based OLED to get it to do something we can observe. From these basic roots, through higher-level subroutines, a complete OLED library in assembly can be constructed. We shall sit tight and await where [Anders] goes next with this!

We see I2C-connected things all the time, like this neat ATtiny85-based I2C peripheral, and whilst we’re talking about the SSD1306 OLED display controller, here’s a hack that shows just how much you can push your luck with the I2C spec and get some crazy frame rates.

Continue reading “A Simple Guide To Bit Banged I2C On The 6502”

BBC Master 128 Revealed

[Adrian] comments that the BBC Master 128 is a rare 8-bit computer, and we agree — we couldn’t remember hearing about that particular machine, although the BBC series is quite familiar. The machine has a whopping 128 K of RAM, quite a bit for those days. It also had a 6502 variant known as the 65C12, which has an extra pin compared to a 6502 and doesn’t use the same clock arrangement. A viewer sent him one of these machines, which apparently was used in the BBC studios. You can see this rare beauty in the video below.

The computer has a very nice-looking keyboard that includes a number pad. There are also expansion ports for printers and floppy disk drives. It has some similarities to a standard BBC computer but has a number of differences externally and internally.

Of course, we were waiting for the teardown about 15 minutes in. There were some corroded batteries but luckily, they didn’t do much damage. The power supply had a burned smell. Cracking it open for inspection was a good time to convert the power supply to run on 120 V, too.

After some power supply repair, it was time to power the machine up. The results were not half bad. It started up with a cryptic error message: “This is not a language.” Better than a dead screen. The keyboard wasn’t totally working, though. A bit of internet searching found that the error happens when the battery dies and the machine loses its configuration.

More walkthroughs will take a bit more work on the keyboard. But we were impressed it came up as far as it did, and we look forward to a future installment where the machine fully starts up.

[Adrian] mentioned the co-processor slot accepting a Raspberry Pi, something we’ve talked about before. Or, add an FPGA and make the plucky computer think it is a PDP/11.

Continue reading “BBC Master 128 Revealed”

Commodore 64 Upgrade In Modern Package

While the Commodore 64 was an immensely popular computer for its time, and still remains a strong favorite within the retrocomputing community, there’s a reason we’re not using modern Commodore-branded computers today. Intense competition, company mismanagement, and advancing beyond 8-bit computers too late in the game all led to the company’s eventual downfall. But if you’re still a Commodore enthusiast and always wished you were able to get an upgraded C64, you might want to take a look at the Commander X16, a modern take on this classic computer.

We’ve actually seen the Commander X16 before, but this was back in its early days of prototyping and design. This video from [Adrian’s Digital Basement], also linked below the break, takes a look at how it’s come in the four years since [David Murray] started this project. At its core, it’s an 8-bit 6502-based computer like you’d find in the 1980s but built with new components. There are some more modern updates as well such as the ability to use an SD card as well as built-in SNES controller ports, but the real magic here is the VERA module. Built around an FPGA, this module handles graphics, some of the audio, and the storage capabilities and does all of these things much better than the original Commodore, while still being faithful to what made these computer great.

While the inclusion of the FPGA might offend some of the most staunch 8-bit purists, it turns out to be necessary due to the lack of off-the-shelf video chips and really makes this build shine in the end. It’s also capable of running 6502-based software from other machines too, including the original NES. The VERA module makes it possible to run other software too, including a sample of Sonic the Hedgehog from the Sega Genesis which [Adrian] demonstrates in his video. 6502-based computers are quite versatile as the Commander X16 demonstrates, and it’s even possible to build a rudimentary 6502 on a breadboard with just a few parts.

Continue reading “Commodore 64 Upgrade In Modern Package”

Hackaday Prize 2023: 65uino 6502 Learning In A Familiar Package

[Anders Nielsen] presents his entry for the 2023 Hackaday Prize: The 65uino. Which as you might be able to guess, is a 6502-based microcomputer wedged into an Arduino Uno form factor (well, almost wedged in, but we’ll let it slide) The premise is simple, older micros are easier to understand, the board can be build up from new-old or salvaged stock, and that’s more chips on boards and less sitting on a dusty shelf. After all, even though the 6502 in its original form is long obsolete, it’s far better to be pushing some electrons around, than sitting there decaying.

The OLED frame buffer is bigger than the host’s entire RAM. No problem!

From an educational perspective, the first lesson is the hand-soldering of through-hole DIP components and a smattering of straightforward surface mount parts in their supporting roles.  Then on to setting up the cc65 toolchain. To say this is a pure 6502 system is a little misleading, it actually uses the 6507 device variant, which is a die-bond variant of the same device but with only 28 of the pins utilized.

The use of the 6532 RIOT (RAM-I/O-Timer) chip provides two 8-bit ports of GPIO as well as a timer and 128 bytes of SRAM, making the design more compact. There is a socket that will accept a 24 or 28-pin E(E)PROM device, with the extra four pins removable and the PCB snapped off if fitment into a standard ‘Uno case is desirable. Neat!

Full hardware build and PCB design (using KiCAD) are available on the 65uino GitHub page. Just remember folks, with everything minimal 6502 related — some assembly required :D

We see the 6502 a lot, let’s be fair. But why not? Here’s a slightly more practical board with a bit more resources, an absolute beast of a luggable dual-6502 machine, and yet another 6502 verilog implementation ready to be dropped into a spare corner of a FPGA project that needs a little extra.

CP/M 6502-Style

There are projects you create to share with the world, but there are also those you do just because you want something for yourself. Lucky for us, [Dietrich-L]’s 30-year-long project to create CPM-65, a CP/M-like OS for the 6502, has become both.

[Dietrich-L] does admit that the documentation is “sparse” and “for my personal needs.” Still, the OS has most of what you’d expect and runs well on the target system, a heavily-modified Elektor Junior with 57 kB of RAM. The disk structure is compatible with CP/M, although the Transient Program Area (TPA) apparently starts at $200, which is a bit different from a typical CP/M. Apparently, the system uses some low memory which necessitated the relocation. Just in case you were hoping, CPM-65 doesn’t emulate an 8080 system, so you can’t run normal CP/M programs. You just get a similar operating environment and tools.

The 31 commands listed include an assembler, BASIC, Forth, an editor, and some disk tools, along with a debugger. Xmodem is available, too. Everything is written in assembly for the CPM-65 assembler, so bootstrapping could be an issue if you need to make any changes.

Speaking of changes, there is some documentation in the docs sub-directory, including the layout of [Dietrich-L]’s system, which would be handy if you were trying to run this on your own hardware. You’ll also find basic commands for the editor, details of the assembler, and some other documents.

[Dietrich-L] notes that he was unaware when he started the project that there were other similar projects. DOS/65 (which has a port for the Commodore 64), OUP/M (which hasn’t been updated since 1983), and CPM65 (apparently no relation, but very impressive), which appeared in 2022.

If you need a 6502 computer, grab a breadboard, although adding the disk drive is an exercise left to the reader. Or, grab an FPGA but expect more work.

Thanks [Stephen Walters] for the tip!

A Guided Tour Of The NES

No matter your age or background, there’s an excellent chance you’ll recognize the Nintendo Entertainment System (NES) at first glance. The iconic 8-bit system not only revitalized the gaming industry, but helped to establish the “blueprint” of console gaming for decades to come. It’s a machine so legendary and transformative that even today, it enjoys a considerable following. Some appreciate the more austere approach to gaming from a bygone era, while others are fascinated with the functional aspects of console.

The NesHacker YouTube channel is an excellent example of that latter group. Host [Ryan] explores the ins and outs of the NES as a platform, with a leaning towards the software techniques used to push the system’s 6502 processor to the limits. Even if you aren’t terribly interested in gaming, the videos on assembly programming and optimization are well worth a watch for anyone writing code for vintage hardware.

Continue reading “A Guided Tour Of The NES”

From A 6502 Breadboard Computer To Lode Runner And Beyond

As disruptive and generally unpleasant as the pandemic lockdowns of 2020 were, they often ended up being a catalyst for significant personal growth. That was often literal growth, thanks to stress eating, but others, such as [Eric Badger], used the time to add skills to his repertoire and build a breadboard 6502 computer and so much more.

For those of you looking for a single endpoint to this story, we’re sorry to disappoint — this isn’t really one of those stories. Rather, it’s a tale of starting as a hardware newbie with a [Ben Eater] 6502 breadboard computer kit, and taking it much, much beyond. Once the breadboard computer kit was assembled, [Eric] was hooked, and found himself relentlessly expanding it. At some point, he decided to get the classic game Lode Runner going on his computer; this led to a couple of iterations of video cards, including a foray away from the breadboards and into PCB design. That led to a 6502 emulator build, and a side quest of a Raspberry Pi Pico Lode Runner appliance. This naturally led [Eric] to dip a toe into the world of 3D printing, because why not?

Honestly, we lost track of the number of new skills [Eric] managed to add to his toolkit in this video, and we’re sure this isn’t even a final accounting — there’s got to be something he missed. It’s great stuff, though, and quite inspirational — there’s no telling where you’ll end up when you start messing around with hardware hacking.

Continue reading “From A 6502 Breadboard Computer To Lode Runner And Beyond”