Microchip introduced the ATmega128Dx in three variants: -DA, -DB, and -DD. These 8-bit microcontrollers can run at 5 volts and have several compelling features. While no "official" Arduino board exists based on these chips, an open-source package adds support to the Arduino IDE: DxCore. I liked the chips so much that I featured them in a Workbench Wednesdays episode.


Unlike the ATmega328p found in the venerable Arduino Uno or Nano, the newer ATmega128Dx chips have a "MegaAVR" core. Frankly, I'm not enough of an expert to explain the difference. However, if you're familiar with the AVR, the MegaAVR is an excellent successor.

Here are seven reasons why I like the ATmega128DB (and its friends) so much.


#1. Works with Arduino

Long story short, I like to call the Arduino IDE the "Arduino library." It is a programming language. Instead, it is a very sophisticated C++ library with a ton of great features.


DxCore adds support for the ATmega128Dx and its Dx variants. (Hence the name.) It implements most, if not all, of the Arduino library's commands. Functions like analogRead() output an analog voltage instead of a PWM signal, like on other boards with a DAC.


#2. Built-in (analog) Op Amps

The aspect I was most interested in is the support for the built-in op-amps. The -DB and -DD have two or three op-amps, depending on the chip's package. Each one has a resistor ladder associated with it, and you can cascade them! So it is possible to build multiple-amplifier stages without using any external components.


Although I point out in the WBW episode, you are somewhat limited to what gains you can get with the built-in resistor ladders.


DxCore's op-amp library makes working with them relatively easy. Instead of setting bits in registers directly, DxCore has some enums that are more friendly to read. For example, in this code, I configured one of the op-amps as a non-inverting amplifier. This code is the example included with DxCore.


#include <Opamp.h>

void setup()
  // Configure opamp input pins
  Opamp0.input_p = in_p::pin;   // Connect positive input to external input pin (PD1)
  Opamp0.input_n = in_n::wiper; // Connect negative input to the "middle" position of the resistor ladder

  // Configure resistor ladder
  Opamp0.ladder_top    = top::output;   // Connect the resistor ladder top to the opamp output
  Opamp0.ladder_bottom = bottom::gnd;   // Connect the resistor ladder bottom to ground
  Opamp0.ladder_wiper  = wiper::wiper3; // Set a gain of two

  // Enable opamp output
  Opamp0.output = out::enable;

  // Initialize Opamp0

  // Start the Opamp hardware


By the way, the ATmega128DA does not feature op-amps! (I found that the hard way.)


#3. Multi-IO Voltages

Using a microcontroller in a system designed for 5 volts goes from comforting to frustrating, like when I was creating the Baldcorder, very quickly. Why? Because so many sensors and peripherals run at 3.3 volts or less. (The TOF sensor we used came on an eval board with a 5 volt level shifter, but it actually ran at 2.8 volts with a max input of 3.2 for the I/O!)


The ATmega128DB and -DD have "multi-IO core" capability. You can reference GPIO pins to a voltage OTHER than Vdd! So you can run the microcontroller at 5 volts, gaining maximum speed, while operating the IO pins at a lower voltage for full capability. Or!


You can operate the ATmega128Dx at 3.3 volts to save power, but interface with a TTL (5 Volt) device, like NeoPixels (ws2812s!)


#4. Internal clock runs up to 24 MHz

Most 8-bit microcontrollers have a built-in oscillator, which is generally limited to a few megahertz. For example, the ATmega328p used in the Arduino Nano only has an internal 8 MHz RC-oscillator.


The ATmega128Dx, on the other hand, can run up to 24 MHz with the internal oscillator and multipliers. So you achieve high performance without the need for an external crystal, resonator, or oscillator circuit.


# 5. It comes in a DIP-28 Package

ATmega128Dx DIP PinoutAs the electronics supply chain continues to move towards surface mount components, it is surprising to see Microchip package such a powerful chip in a DIP.


You give up some flexibility with the pins and at least one op-amp when moving from a surface-mount package to a through-hole DIP.


But it is nice to build a breadboard-friendly 24 MHz microcontroller circuit that only needs a couple of decoupling capacitors.


# 6. So. Much. Analog.

I have gushed enough about the built-in operational amplifiers. There is also an analog-to-digital converter, a digital-to-analog converter, PWM pins, plus more. And unlike the older the 328p, there is far more flexibility to which pin does what. (There is an eye chart in the datasheet.)


The feature that caught my attention was the built-in op-amps. In other Microchip designs, like the SAMD21, there are configurable amplifiers on the ADC inputs. These op-amps seem to be an extension of that design.


Other analog features include a 10-bit DAC, three analog comparators, three zero-cross detectors, and a 12-bit ADC! Plus, all of the digital busses you'd expect to find on an 8-bit microcontroller like I2C.


#7. UPDI Programming

While I am not excited about "yet another programming standard," I am very happy with UPDI. It is a one-wire programming and debug interface. You can program an Arduino-Nano to act as a programmer to program ATmega128Dx chips. In the Op-Amps without Op Amps workbench Wednesdays episode, that is why I had a Nano clone on the breadboard. It is now my dedicated UPDI programmer. (Well, it was, until the other day when I broke off the USB connector. But that's a story for another post.)



The entire ATmega128Dx series of chips are interesting. Although, I am not sure why you might pick a -DA over a -DB or -DD. The -DA lacks several core features that the others have, and they aren't that much cheaper.


Frankly, I do not know how long the ATmega328p has been around. But I know its predecessor, the ATmega8, has been in use for a long time. So to see a chip with a similarly easy-to-work-with core equipped with modern features is exciting.


Have you checked these chips out? If so, what do you think about them?