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”

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.

RiotNAS: Mobile Storage For Street Photography


You’re likely aware of the protests and demonstrations happening throughout Venezuela over the past few months, and as it has with similar public outcries in recent memory, technology can provide unique affordances to those out on the streets. [Alfredo] sent us this tip to let us know about riotNAS: a portable storage device for photos and videos taken by protesters (translated).

The premise is straightforward: social media is an ally for protesters on the ground in these situations, but phones and cameras are easily recognized and confiscated. riotNAS serves up portable backup storage via a router running OpenWRT and Samba. [Alfredo] then connected some USB memory for external storage and a battery that gives around 4 hours of operating time.

For now he’s put the equipment inside a soft, makeup-looking bag, which keeps it inconspicuous and doesn’t affect the signal.  Check out his website for future design plans—including stashing the device inside a hollowed out book—and some sample photos stored on the riotNAS system. If you’re curious what’s going on in Venezuela, hit up the Wikipedia page or visit some of the resources at the bottom of [Alfredo’s] site.