Programming an ATMega128

We tried all kinds of ways to get the Arduino IDE to compile and program our ATMega128 chips that we’d so carefully soldered onto our breakout boards. Steve spent longer than could be reasonably expected, hammering away, determined to make progress. In fact, he got so far as to get Arduino 022 to compile some code for the AT Mega – it just wouldn’t upload via the USB Tiny programmer
While Steve refused to give up, I went down a slightly different route. Having recently discovered that the latest Oshonsoft AVR Simulator included support for both the ATMega128 and ATMega165, I threw together a simple blink test and compiled to a .hex file (which the compiler did a great job of creating, at a meagre 240 bytes in size!)
With the Oshonsoft compiler creating the hex file, we were both neck-and-neck: hex file built, just the programming to go. Steve spent a while messing about with the USB Tiny config files, trying to add in support for the ATMega128 but the nearest he got to completion was an error message in the avr-gc executable – highlighting the character “h” at the beginning of an innocuous looking entry in the modified config file.
In the meantime, I was having problems of my own.
Programming an ATMega128
Despite always running my laptop in “disabled digital driver enforcement mode” there was something about the USBASP programmer that Windows 8.1 really doesn’t like. I had to reboot the laptop twice; both times to disable digital signature signing, to enable the device to work. (there are plenty of links on the net about how to disable digital signing so there’s no need to go into detail here – except to say that a lot of guides are out of date and that the location of different settings has changed under Windows 8.1 in the later updates; I spent ages only to discover that the settings I wanted were no longer under “general” but “restore pc”)

Having finally got the us asp device installed, it was time to stick some code onto the chip. Taking extra care to wire the programmer to the breakout board, I downloaded and installed a GUI front-end for the command-line programming tool avr-dude (called AVR Dudess).
It’s worth noting that for the ATMega128, the programming lines are on pins 2+3 (the PDI/PDO lines) and not the dedicated SPI MISO/MOSI lines as suggested by some sources. It’s important to route the programmer to the PDI/PDO lines if you’re building a programming header onto your project!

Leave a Comment

Your email address will not be published. Required fields are marked *