Breaking out of the Chip Shortage – Attempt #3

The ATMEGA4808 provides a very attractive solution to replace the trusted ATMEGA328 or standard Arduino UNO /NANO.

These chips are slightly more difficult to get hold of than the ATTiny chips, and cost a little bit more ( about the same as what the ATMEGA328 used to cost before the mess with COVID-19 and resulting supply chain shortages + inflated costs), but they offer all of the functions of the ATMEGA328, with a few other enhancements that will definitely be very useful.

The extras include:
– Hardware interrupts on ALL GPIO pins; This is way more than the standard 2 interrupts on the ATMEGA328 ( We are not talking about the Pin Change interrupts, but real hardware interrupts, that can be triggered on RISING, FALLING, CHANGE, HIGH and LOW state of each pin

– Up to eight (8) PWM pins as opposed to the 6 on the Arduino UNO
– Up to eleven Analog inputs
– An Analog Comparator module
– Configurable Custom Logic (CCL)
– EVENT System (EVSYS)
– Peripheral pin swapping

It is also worth mentioning that these chips have accurate internal oscillators, capable of clocking the chip at up to 20MHz, further reducing the number of external components required to get a minimal configuration running…

Order your own version of this development board

The Prototype PCB

While I have had a Nano Every “Clone” lying in a drawer for quite a while now, I did not really pay a lot of attention to it. That was, until I needed an ATMEGA328 for a project, and could not find any for sale, or at least at a price that I was willing to pay for it… That incident was the spark that ignited this entire exercise, to find a suitable replacement…

The Nano Every “Clone” in my possession, used the ATMEGA 4808 chip and turned out to be the Thinary Nano 4808. I had quite a lot of problems with the provided core, as well as getting peripherals like I2c and SPI to work. This led to further investigations, and finally, I decided on building my own and to use the MCUdude/MegaCoreX Arduino Core to program it.

This led to the following prototype:

ATMEGA4808 Development board prototype

I did not bother with too much detail on the silk screen here, as the goal was to get a working board, test it, and then later, design a refined PCB.

What is important to note is that the board runs at 5v, but provides a single 3.3v output as well. Logic levels on the GPIO is also 5v. Use level converters for 3.3v only addons…

The MEGA4808 is programmed via UPDI, so we have a UPDI Header on the right-hand side of the PCB. It is also possible to use the Optiboot Bootloader, to flash the board in true Arduino style through a USB connection to a computer.

A CH340N USB-to-Serial converter chip is used instead of the CH340G that is common on the UNO clones. The CH340N provides only the USB D+ D- signals, as well as Rx, TX and RTS. RTS is being used to auto-reset the chip after flashing…

In comparison to the CH340G, which also required a crystal oscillator, but provides all the modem control signals, which, are usually not even broken out, the CH340N made much more sense.

PCB Bottom.

A power LED, as well as an indicator LED on pin 7 was also included.

Assembled PCB, Top Layer.

Assembly and Soldering

I normally assemble all my projects by hand and reflow-solder them with a hot plate. for this project, I decided to do things a bit differently, which ended up being a bit awkward, but still resulted in a perfectly useable PBC.

As you will know by now, I only do written articles, as I don’t consider myself ready for the Youtube and video thing, as well as because I believe a well-written article, with detailed pictures, is easier to understand than a video…

Well, today, we will have both… This article, with its writeups and pictures, as well as a short assembly and soldering video, with no sound, sped up 5x, as I did not want to bore anyone with a 25-minute silent video…

Let us begin then…

PCB and Stencil

We start with a blank PCB and the laser-cut stainless steel stencil that I got from PCBWay.

Solder paste applied

Solder paste is then applied with the stencil and a scraper, and afterwards, the stencil is removed… The PCB is now ready for component placement…

From here on, we will go to the video footage… showing component placement, with some awkwardness due to the camera being in the way, as well as hot-air soldering, with the same awkwardness, as I was forced to use my right hand ( I am left-handed), not to block the camera view…

Begin quite new to the video thing, I have also not quite figured out the editing software, so the video is in native resolution… not zoomed…

After assembly

After assembly, I checked for solder bridges and was quite happy that there were none. This also meant that the board worked perfectly the first time around… as it should…

Order your own version of this development board

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Picture Gallery

Breaking out of the Chip Shortage – Attempt #2

The ATTiny1616 is a step up from the ATTiny202, having more GPIO, flash and RAM. This makes it ideal for bigger, but still medium size projects that do not need all the power of the traditional Arduino.

In Part 1 of this series, I took a quick look at the ATTiny202 MCU from Microchip. Having only 5 useable GPIO, with limited Flash and Ram, that little chip was still quite useful for some of those very small projects, where we did not really need a lot of peripherals and GPIO pins.

Today, we shall take a step up, and take look at a slightly bigger MCU, the ATTiny1616, this time with up to 17 GPIO pins, more flash and memory, and still quite easy and cheap to get hold of. (Current Prices are in the range of about $1USD to $2USD, depending on where you buy and how many you buy).

As I wanted to give myself a bit of a challenge with this project, I decided on using a QFN package this time, which, being extremely tiny, only 3mmx3mm, will give most Makers a pleasant challenge to solder correctly. ( I am planning a SOIC 20 version, but with a bit more external hardware onboard)

MakerIoT2020 ATTiny1616 Minimal Breadboard-friendly breakout

The ATTiny 1616 is part of the tinyAVR-1 series, which includes the 1614,1616, and 1617, and they have the following features ( copied from the datasheet link above)

The ATtiny1614/1616/1617 are members of the tinyAVR® 1-series of microcontrollers, using the AVR® processor with hardware multiplier, running at up to 20 MHz, with 16 KB Flash, 2 KB of SRAM, and 256 bytes of EEPROM in a 14-,20- and 24-pin package. The tinyAVR® 1-series uses the latest technologies with a flexible, low-power architecture, including Event System, accurate analog features, and Core Independent Peripherals (CIPs). Capacitive touch interfaces with Driven Shield+ and Boost Mode technologies are supported with the integrated Peripheral Touch Controller (PTC).

ATTiny 1616 Breakout – Bottom view

The PCB – Minimal working configuration – with a few extras

The PCB break-out all 18 of the GPIO pins, while it is only recommended to use 17 of them, unless, like in the case of the ATTiny202, you have access to an HV UPDI programmer. It also becomes possible, although still being quite tedious and awkward, to use the OptiBoot Bootloader on this chip, although it is still not quite recommended. Just using a UPDI programmer, with a separate USB-to-Serial adapter on another port is still definitely the easiest.

The Board contains an LED, on PIN_PA4, Arduino Pin 16, as well as onboard I2C pull-up resistors, selectable via a jumper. It is important to note that the current version DOES NOT contain a voltage regulator on the PCB. It is up to you to provide a regulated voltage source, in the range of 1.8v to 5.5v DC

It is recommended to clock the Chip at 16MHz when running at 5v ( 20Mhz is possible, But I did not bother to test that yet)
8Mhz when running at 3.3v
0-5Mhz when running at 1.8v

See the Datasheet, as well as the megaTinyCore documentation for exact details on this.

Commonly used peripherals, by myself, are listed on the back of the PCB for easy reference.

Order your own version here.

Programming the board

Programming is possible with Arduino IDE (and platformIO, ( I didn’t test that, as I find VS-Code tedious to use ), as well as MPLab from Microchip.
For the Arduino IDE, you have to install the megaTinyCore Arduino Core, as already mentioned above. ( This also apparently works for PlatformIO)

Full instructions, as well as some very useful other tips and information, is available in the core documentation, so do put in the effort to actually read the documentation. You won’t be sorry that you did.

The Schematic

Schematic

Design and Assembly

PCB layout

The board is designed as a double-layer PCB, with ground planes on both sides.

Due to the MCU package having a QFN footprint, using a proper SMD stencil is strongly recommended.

SMD Stencil – Make things a bit easier.

Hot-Air or a hotplate will also be quite useful to ensure success with this project. Passive components can be hand soldered though.

Manufacturing

I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Picture Gallery

Get Started with the ATMegaTiny202

As I have hinted in my recent two posts about UPDI programmers, I am currently looking for a solution to replace the ATMEGA328P chip used in standard Arduino devices, like the UNO and NANO.

The global chip shortage seems to be still hitting hard, with these devices (Arduino UNO, NANO), and even bare chips being quite hard to get hold of, and when you do, they are quite more expensive than they used to be.

This sent me on a new journey, to find a new chip, that is easy to use, inexpensive, and easy to get hold of. I have found 3 of these chips, starting today with the ATMEGATiny202,

ATMEGATiny 202



The ATtiny202 is a microcontroller using the 8-bit AVR® processor with a hardware multiplier, running up to 20 MHz and 2 KB Flash, 128B SRAM, and 64 bytes of EEPROM in an 8-pin package. The series uses the latest technologies from Microchip with a flexible and low-power architecture, including Event System and SleepWalking, accurate analog features and advanced peripherals.

With only 8 pins, of which we can practically use only 5 ( 6 if you have an HV UPDI programmer ). This makes it a desirable solution for small projects, with its current price of about 0.59 USD per chip ( SOIC8 PACKAGE, Element14 ) , not breaking the bank either. Not needing an external oscillator, and requiring only a single 100nf bypass capacitor, (not counting the UPDI resistor) it can indeed be a very very cheap way to get a project done… Providing of course that you don’t need a lot of Program memory or RAM, and are not trying to do too many super fancy or complicated things.

ATMegaTiny202 Minimal Breakout, on Breadboard with MakerIoT2020 Multipurpose Uart/UPDI Programmer

The wide operating voltage of 1.8v right up to 5.5v also makes it quite flexible.

My initial prototype

Getting started with a new chip is also a bit of an issue, as there are many new things to learn, recommended supporting components, and also firmware and cores that need to be installed. I have decided to build a quick breadboard-capable PCB, with all 8 pins broken out in a single row, feel free to change the straight header pins to a 90-degree version at your convenience, it takes up even less space that way.

The PCB contains only the bare minimum required components for the chip to function, but I also added onboard I2C pullup resistors, with a jumper to select them. ( Most I2C modules usually have these already, but as I build most of my own breakouts myself, I decided to include these).

A single LED brightens things up a bit, connected to pin PA3, making it possible to run a blink sketch…

The rest of the components include a 100nf bypass capacitor and the very important 470ohm UPDI resistor.

ATTiny202 Breakout-Blank PCB-Top
PCB Top view, unpopulated
PCB Bottom, unpopulated

Programming the board

I use the Arduino IDE quite a lot, and also assume that most makers and hobbyists out there will do the same. Luckily we have access to a special Arduino core, the megaTinyCore, that provides us with all we need to program this tiny little chip, provided of course that you have a UPDI programmer.

See the link above for installation instructions, as well as detailed documentation. Replicating all of that here will be an unnecessary task, as the author of the core, SpenceKonde, has already done an excellent job.

One very important thing to note on this board is that there is NO RESET PIN.
You have to manually cycle power to it, but, I have found that initiating a UPDI upload to a running chip works every time, and makes it unnecessary…

The reason for the lack of a reset pin lies in the fact that the reset is shared with the UPDI pin, and enabling it, will rob you of the UPDI functionality UNLESS you have an HV UPDI programmer, which at this time seems to be hard to find/expensive item ( Hope to build my own soon). Once again, see the above link to the core documentation for the full information on the reset pin issue…

I can not stress enough how important it is to sit down and READ the core documentation, with attention, before doing anything with this chip and core. you will learn a lot, about the chip, new features, possible problems, and how to avoid them, and also some customised GPIO functions etc…

Schematic

ATTiny202 Minimal Schematic

Manufacturing

PCB Layout

The PCB is a double-layer PCB, with the signal traces on the top layer, power traces, and the ground-plane, on the bottom layer. the Dimensions are 26.035mm x 18.669m. All SMD components are 0805. This board does not need a stencil for assembly and can be hand or hot-air soldered in a few minutes with no problems.

As many of my existing readers will know by now, I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Picture Gallery

Small and Cheap UPDI Programmer

UPDI programmers are a new necessity in my lab, as I continue my quest to find a suitable replacement for the old Atmega328P chips (More on that in another post). In a previous post, I showed you a combination UART/UPDI programmer module that I have recently designed. It would only be fair to show you where that started out, as a single-purpose UPDI programmer, based on the CH340N.

The CH340N has, according to me at least, some advantages over the CH340G in the sense that it requires very few external components, most notably that it doesn’t require an external crystal oscillator. It does however NOT provide you with all the Modem signal lines (RTS, DTS, DTR, CTS etc) that you get on the CH340G, although most people will not use most of those anyway…

The cost of the two chips is about the same, with the CH340N being slightly more available at the moment, at least in my part of the world.

The particular circuit that I am using originated from Stefan Wagner. I simply designed my own PCB around his circuit. Credit is given where it is due, as I found his site, and content extremely detailed and accurate.

While this is a serial UPDI programmer, with NO HV capability, I do find it extremely useful as a test project, and while I may invest in a proper HV UPDI programmer in the future, if the bigger part of the project plays out the way I anticipate, for the time being, this is exactly what I need.

Order your own here

What is on the PCB?

3D Render of the UPDI Programmer

The PCB is quite small, with a low component count, 6 capacitors, 4 of which is smoothing capacitors, two resistors, one Power on LED indicator, a 3.3v voltage regulator, USB connector ( Type B Mini) and of course the CH340N and a few header pins, one of which is used as a target voltage selector by means of a jumper. I did not bother with a switch as this pushes the cost of the device up by quite a bit.

Current costs for the components are around 5USD excl shipping at LCSC.

So, J1 is used to select the target voltage between 3.3v and 5v.
The other header provides VCC ( marked V+), GND and the UPDI output.

The Schematic

Schematic

Manufacturing

As many of my existing readers will know by now, I choose PCBWay for my PCB manufacturing. Why? What makes them different from the rest?

PCBWay‘s business goal is to be the most professional PCB manufacturer for prototyping and low-volume production work in the world. With more than a decade in the business, they are committed to meeting the needs of their customers from different industries in terms of quality, delivery, cost-effectiveness and any other demanding requests. As one of the most experienced PCB manufacturers and SMT Assemblers in China, they pride themselves to be our (the Makers) best business partners, as well as good friends in every aspect of our PCB manufacturing needs. They strive to make our R&D work easy and hassle-free.

How do they do that?

PCBWay is NOT a broker. That means that they do all manufacturing and assembly themselves, cutting out all the middlemen, and saving us money.

PCBWay’s online quoting system gives a very detailed and accurate picture of all costs upfront, including components and assembly costs. This saves a lot of time and hassle.

PCBWay gives you one-on-one customer support, that answers you in 5 minutes ( from the Website chat ) , or by email within a few hours ( from your personal account manager). Issues are really resolved very quickly, not that there are many anyway, but, as we are all human, it is nice to know that when a gremlin rears its head, you have someone to talk to that will do his/her best to resolve your issue as soon as possible.

Find out more here

Pictures of the PCB and Assembled Module

Assembly

I assemble all of my projects by hand, using hot air and or a hotplate for reflowing. Having an accurate stencil for applying just the right amount of solder paste becomes a necessity very quickly.
In future, I plan to have a dedicated section showing the assembly of some of the more challenging boards…

Multipurpose USB UART Module

USB-to-Serial converters are some of the most used modules on my bench. I have quite a few of them, most of them are the cheap online type that can be had for a few dollars.

As part of my new project, where I am seriously looking for an alternative chip to replace the ATMEGA328, which has become almost impossible to get, and super expensive when you do get it, I needed to get hold of a UPDI programmer.

There are many available online, from cheap to more expensive, but I wanted to build my own, as it did not seem too difficult to do.

As another part of my daily tasks, I also use a lot of ESP-type chips, which have a particular procedure to upload code via an external serial adapter.

The idea was thus to design a USB UART module that has multiple purposes, as well as being easy and cheap to assemble.

  • Be able to program ATMEGA328 Chips via Serial
  • Be able to be used as a standard USB-to-UART adapter
  • Be a UPDI programmer
  • Have a selectable target voltage between 3.3v and 5v
  • Have all modem signals (RTS, CTS, DSR, DTR) broken out.
  • Be able to auto-flash and reset an ESP32 or ESP8266 device, or similar
Breadboard Prototype Multipurpose USB-to-UART/UPDI Programmer

What is on the PCB?

The PCB is powered by the PC USB port. The target device voltage is selectable between 3.3v and 5v. The device mode can be changed from UART to UPDI mode with a jumper. An additional header specifically for ESP32/ESP8266 devices is provided, giving access to the FLASH and reset signals for the ESP device.

The USB to serial conversion is taken care of by a CH340G Chip, which provides all the relevant modem signals as well.

All signals, with the exception of the “RING” signal, are broken out onto the main header.

Note that there are NO status or POWER LEDs on the board. This was on purpose, as these sometimes interfere with the UPDI programming mode.

Prototype PCB – Assembled

PCB – Top
PCB – Bottom

Connecting to different devices

ESP32 or ESP8266 Devices

When in UART mode, the device can be used to upload code to an ESP32/ESP8266 automatically, similar to a standard dev board, without requiring you to press and flash and reset buttons.

This is achieved by connecting the device as follows:

UART MODULE SET to 3v
UART VCC to ESP 3v
UART GND to ESP GND
UART RX to ESP TX
UART TX to ESP RX

(Connections for Auto Upload/Reset)
UART RST ( on ESP-Flash Header) to ESP RST
UART GPIO0 ( on ESP-Flash Header) to ESP GPIO0

It will now be possible to flash and auto reset the connected ESP device from the Arduino IDE, and possibly others as well…

Arduino (Atmega 328P)

In the current version of the prototype, you have to connect it as follows:

UART Target voltage set to 3v or 5v depending on what type of board you are uploading

UART Tx to Arduino Rx
UART Rx to Arduino Tx
UART VCC to Arduino 3v or 5v ( depending on the target voltage required by the board you are flashing)
UART GND to Arduino GND

To allow for auto flash/reset on the Arduino, a 100nf capacitor is required between the UART DTR line and the Arduino Reset pin. This capacitor has NOT yet been fitted onto the PCB, as I usually use ICSP to upload these. Future versions of the PCB shall have this included.

ATMEGA4808/4809 and or ATTiny with UPDI Interface

This device is currently an LV-only UPDI programmer. Connections are as follows:

Set Target voltage on J1 of the UART/UPDI programmer.
Set The Device mode on J2 to UPDI mode

Connect VCC and GND from the Programmer to the target chip/board
Connect Programmer UPDI pin( shared with RxD) to Target UPDI pin.

General use UART for use as Serial monitor/Terminal

Set target voltage on J1
Set device mode to UART on J2

Connect VCC, GND from UART to the target device,
UART Tx to Target Rx
Uart Rx to Target Tx

Optionally connect required modem signals, RTS, CTS, DTR, and DSR as needed

Manufacturing

The PCB for this project has been manufactured at PCBWay.
Please consider supporting them if you would like your own copy of this PCB, or if you have any PCB of your own that you need to have manufactured.

PCBWay

Some Links to things used in the project

MakerIoT SMD Prototyping Breadboard
Order this PCB from PCBWay