In this guide to programming ATtiny MCUs, learn how you can program your MCU before assembly!
The previous two programming methods involved ways of programming microcontrollers after the PCB has been assembled:
For the majority of products, programming is done as part of the assembly process after the boards are assembled.
However, another option is to program the microcontrollers first and then assemble the PCBs. Although it is generally advisable to include some kind of programming interface in your designs whenever possible, there are a couple of situations when it might not be feasible to add programing headers to a design:
- You are building an extremely compact design in which there is no space to spare for programming pins or for interfacing a programmer with the PCB.
- You are building a simple device with software that is unlikely to change or require updates.
- You are designing a device in which the PCB is sealed, over-molded, or fully enclosed in some kind of housing, rendering it permanently inaccessible.
Using pre-programmed microcontrollers is also used more commonly with very large order quantities of several thousand units at least in order to make the parts more cost-effective.
Purchasing Pre-Programmed Microcontrollers
It is actually relatively easy to purchase pre-programmed microcontrollers. DigiKey, for example, advertises its programming service on some of the microcontrollers and other programmable parts in their catalog.
DigiKey offers a programming service on many of its parts
Often, the manufacturers of microcontrollers will offer programming services directly. This is true of Microchip Technology, the company that manufactures ATtiny microcontrollers, among a wide range of other electronics products.
Usually, the cost of programming, plus other value-added services like placing an ink dot on the microcontroller to indicate it has been programmed, is only feasible at large order quantities. For example, with Microchip Technology, the cost of pre-programmed ATmega328p microcontrollers is 25% cheaper at quantities over 5000 units compared with orders under 500 units.
Many microcontroller manufacturers offer pre-programmed ICs directly.
How to Program an ATtiny MCU Using an SMT Test Socket
It is possible to program ATtiny-series microcontrollers directly for the purposes of testing the process and other assembly stages prior to ordering a large quantity of pre-programmed chips. There is a specialized tool for this purpose called an SMT test socket.
This is an SMT test socket for SOIC-20 medium chips, like the ATtiny85
The test socket works a bit like an IC test clip. It is designed to fit a specific surface mount package. In fact, you could use an IC test clip to directly program bare ATtiny microcontrollers, but getting the clip to hold the ICs without them being soldered to a PCB is a little tedious and unreliable. On the other hand, the test socket holds the microcontrollers securely.
To use an SMT test socket press down on the top of the socket to open the contacts, place the microcontroller into the socket, and release the socket to engage the electrical contacts. The SMT test socket will both hold the microcontroller securely in place and enable reliable electrical connections with the chip.
The SMT test socket simply breaks out each of the legs on the SMD ATtiny microcontroller to breadboard-friendly headers. Therefore, using the SMT test socket, connections can be made to any of the pins on the SMT package.
With an SMT test socket, it is possible to program the microcontroller using an ISP programmer, USB AVR programmer, an Arduino programmed as an ISP programmer, or basically any other programming technique just by creating the appropriate connections on a breadboard between the chip and the programmer.
After connecting the programmer to the microcontroller, the rest of the programming process is the same while using an SMT test socket as it is using the same programmer with any other method of connecting to the chip.
A Variety of ATtiny MCU Options
If you are working on building a more compact and efficient design for your next project or if you are working on bringing a new product to market, ATtiny series microcontrollers are a great way to transition from an Arduino-powered prototype to a custom PCB.
There are several different ATtiny microcontrollers with various capabilities including differing numbers of I/O pins, different amounts of flash memory for program storage, different analog-to-digital pin availability, and different PWM outputs.
Different ATtiny MCU Programming Methods
Depending upon the scale of your project or the number of products you need to manufacture, there are several common methods for programming ATtiny series microcontrollers: using an IC test clip, using an ISP header on the PCB, or using pre-programmed chips.
Each of these programming methods is useful on designs at various stages between prototyping and production and for the production of varying quantities of a PCB design.