[Juan] sent us his writeup of a microcomputer he built using an Arduino UNO (AVR ATmega328p) and some off-board SRAM. This one’s truly minimalistic.
Have a look at the schematics (PDF). There’s an Arduino, the SPI SRAM, some transistors for TV video output, and a PS/2 connector for the keyboard. That’s it, really. It’s easily built on a breadboard in a few minutes if you have the parts on hand. Flash the Dan64 operating system and virtual machine into the AVR and you’re good to go.
Now we’ve seen a few 6502-based retro computers around here lately that use a 6502 paired with a microcontroller for the interfacing, but they’ve all been bulky three-chip affairs. [Juan] wins the minimalism prize by using a 6502 virtual machine implemented in the AVR to reduce the parts count down to two chips for the whole shooting match.
Using a 6502 virtual machine was a crucial choice in the design, because there are 6502 cross compilers that will let you compile and debug code for the microcomputer on your macrocomputer and then load it into the micro to run. This makes developing for the micro less painful.
How does it load programs you ask? The old-fashioned way of course, using audio files. Although rather than using the Kansas City Standard as in days of yore, he encodes the data in short and long pulses of square waves. This might be less reliable, but it sure saves on external hardware.
Continue reading “The Dan64: A Minimal Hardware AVR Microcomputer”
[Josh] has written up two posts that those of you who use AVRs might find handy. The first post documents a C library that implements a jitter-free one-shot timer. The second post explains how it works. We think it’s such a good idea that we’re going to spoil it for you, but go ahead and read his links and check out his code.
A one-shot is a pulse generator that runs once and only once. You trigger it, it produces the desired pulse, and that’s all she wrote. Why is this handy? Many external ICs that you’ll interface with have minimum durations for signal pulses that must be respected. You could program the AVR to toggle a pin high and then sit around and wait until it’s time to toggle the pin low again, but this wastes valuable CPU time, isn’t going to be very precise, and is susceptible to timing discrepancies if interrupt routines fire in the mean time.
You’d think that you could use the hardware timers for this, but it’s not straightforward. Normally, the timers are free-running; the counter that’s keeping track of time rolls over the top and starts over again. But we just want one pulse.
[Josh]’s very clever idea abuses the timer/counter’s TOP and MATCH values in “Fast PWM” mode. Essentially you trick the counter into never matching by setting TOP below MATCH. This means that the counter spins in its loop between zero and TOP forever, doing nothing.
To break it out of its loop and enable the one-shot, you manually set the counter to a value above TOP and let it go. As it counts up, it’ll eventually hit MATCH, turn on your pin, and then keep counting. When it rolls over the top (255 + 1 = 0 for the 8-bit AVRs), your pin will be correctly turned off again and then the counter re-enters its loop. The one-shot won’t fire until you manually set the counter higher than TOP again.
So there you have it, a one-shot depending only on the hardware timer/counter module and thus immune to jitter and consuming no CPU time at all. Our hats off to you, [Josh]. Clever hack.
Back in the bad ‘ol days of computing, hard drives cost as much as a car, and floppy drives were incredibly expensive. The solution to this data storage problem offered by all the manufacturers was simple – an audio cassette. It’s an elegant solution to a storage problem, and something that has applications today.
[Jari] was working on a wearable message badge with an 8-pin ATTiny. To get data onto this device, he looked at his options and couldn’t find anything good; USB needs two pins and the firmware takes up 1/4 of the Flash, UART isn’t available on every computer, and Bluetooth and WiFi are expensive and complicated. This left using audio to send digital data as the simplest solution.
[Jari] went through a ton of Wikipedia articles to figure out the best modulation scheme for transferring data with audio. What he came up with is very simple: just a square wave that’s changed by turning a pin off and on. When the audio is three samples long without crossing zero, the data is 0. When it’s five samples long without crossing zero, the data is 1. There’s a 17-sample long sync pulse, and with a small circuit that acts as a zero crossing detector, [Jari] had a simple circuit that would transfer data easily and cheaply.
All the code for this extremely cheap modem is available on GitHub.
If you want to program an AVR chip as inexpensively as possible, then [Ian’s] solution might just be for you. He built an AVR programmer using only four components. This design is based on the vusbtiny AVR programmer design, with a few components left out.
[Ian’s] design leaves out two of the resistors and two diodes, leaving just four components. These include a 1.5k resistor, a small capacitor, a USB connector, a six pin header, and an ATtiny45. He admits that this may not be exactly up to USB spec, but it does work.
This is one of those projects that is really an exercise in “will it work?” more than anything else. The fact that you need to first program an AVR chip means that this wouldn’t be useful in a pinch, because you would already have to have a working programmer. Nonetheless, it’s always fun to see what can be done with as little as possible.
[Neven Boyanov] says there’s nothing special about Tinusaur, the bite-sized platform for learning and teaching the joys of programming AVRs. But if you’re dying to gain a deeper understanding of your Arduino or are looking to teach someone else the basics, you may disagree with that assessment.
Tinusaur is easy to assemble and contains only the components necessary for ATTiny13/25/45/85 operation (the kit comes with an ’85). [Neven] saved space and memory by forgoing USB voltage regulator. An optional button cell mount and jumper are included in the kit.
[Neven] is selling boards and kits through the Tinusaur site, or you can get the board from a few 3rd party vendors. His site has some projects and useful guides for assembling and driving your Tinusaur. He recently programmed it to play Conway’s Game of Life on an 8×8 LED matrix. If you’re looking for the zero-entry side of the AVR swimming pool, you can program it from the Arduino IDE. Be warned, though; they aren’t fully compatible.
The project featured in this post is an entry in The Hackaday Prize. Build something awesome and win a trip to space or hundreds of other prizes.
A bootloader is typically used to update application code on a microcontroller. It receives the new program from a host, writes it to flash, verifies the program is valid, and resets the microcontroller. Perhaps the most ubiquitous example is the Arduino bootloader which allows you to load code without an AVR programmer.
The bootloader resides in a special part of memory, which is protected. On the AVR, it isn’t possible to write to the bootloader memory from the application code. This is to prevent you from accidentally breaking the bootloader and bricking the device.
However, it can be useful to write to the bootloader memory. The best example would be when you need to update the bootloader itself. To accomplish this, [Julz] found a workaround that defeats the AVR bootloader protection.
The challenge was to find a way to execute the Store Program Memory (spm) instruction, which can only be executed by the bootloader. [Julz] managed to make use of the spm instruction in the existing bootloader by counting cycles and modifying registers at the right time.
Using this technique, which [Julz] calls BootJacker, the Fignition 8 bit computer could have its bootloader updated. However, this technique would likely allow you to modify most bootloaders on AVR devices.
[Thomas] tipped us about his latest project: a stand-alone AVR programmer module named ISPnub. As you can see in the picture above, it is a simple circuit board composed of a main microcontroller (ATmega1284p), one button and two LEDs. Programming a target is a simple as connecting the ISPnub and pressing the button. The flashing operation success status is then shown using the green/red LED.
ISPnub gets its power from the target circuit so no external power supply is needed. It works over a wide voltage range: 1.8V to 5.5V. The module also features a programming counter which can be used to limit the number of programming cycles. A multi-platform Java tool is in charge of embedding the target flash contents with the ISPnub main firmware. The complete project is open source so you may want to check out the official GitHub repository for the firmware and the project’s page for the schematics.