A simple and inexpensive way to program new AVR ATtiny214, ATtiny414, ATtiny814 and Atmega microcontrollers using by the UPDI interface
Recently Microchip Technology started selling new 8-bit ATtiny214 / ATtiny414 / ATtiny814 microcontrollers, as well as Atmega. In new microcontrollers, programming is carried out through the UPDI interface instead the SPI protocol. On the one hand, this innovation expands possibilities in the development of electronics. For programming the microcontroller only one pin is used. On the other hand, the transition to a new programming algorithm (this concerns the hardware part) raises many questions. Official technical documents on the use of the UPDI interface do not contain comprehensive information on the wiring diagram and programming of these microcontrollers. The purpose of this article is to master a simple and inexpensive way to program ATtiny214 / ATtiny414 / ATtiny814 microcontrollers, as well as Atmega with UPDI interface.
There will be a small digression. In our opinion, 8-bit AVR ATtiny214 / ATtiny414 / ATtiny814 microcontrollers from Microchip have a fairly good price / functionality ratio. These microcontrollers are suitable for projects that require simple basic functions such as: PWM, DAC, ADC, comparator, timer, etc. You can also implement quite complex projects using by these microcontrollers. A complete description of the microcontrollers can be found on the official website https://www.microchip.com. For example, for Attiny414, this is https://www.microchip.com/wwwproducts/en/ATTINY414.
We now turn to the preparation of the workplace. Conventionally, we divide preparation of this workplace into 2 parts. Part 1 is the installation of the necessary software on the computer. Part 2 is the preparation of hardware part for programming microcontrollers. 1 First you need to install software on your computer. 1.1 First of all, install the official version of Atmel Studio https://www.microchip.com/mplab/avr-support/atmel-studio-7. Atmel Studio 7 is currently available. 1.2 After installing Atmel Studio 7, we need to install the latest Python programming language https://www.python.org/downloads. Currently version 3.7.3 is available. Python is a cross-platform and open source programming language. Installing Python is only required to run the working script on the computer. The script will flash the Attiny microcontroller using our .hex file. We will get this .hex file when compiling our program using by Atmel Studio 7. Programming in Python in this case is not required. 1.3 Download Project updipy https://github.com/mraardvark/pyupdi. On this page at the top (above the middle of the page) on the right will be the tab "Clone or Download". Click on it. The tab will open and there will be a link "Download ZIP". Click on it and download the project to your computer. We recommend unpacking the project in the directory C: \ Users \ User. This is done for simplicity. Since the command line defaults to this particular directory. All project files and folders should be in the same directory. Pyupdi is launched via the pyupdi.py script in computer’s command line. Of course, you can create an environment variable in order to set up a script path directory there. For pyupdi.py, you will also need to install additional modules: intelhex, pylint, pyserial. You can install these modules via the command line of the computer using by the command “pip installpylint” for the pylint module. A similar command will be required to install other modules.
So, we briefly describe the logic of the installed software. a) We create a simple program for working the Attiny414 microcontroller using by Atmel Studio 7 . We create a program that turns on / off the voltage on PB1 pin. A LED is connected to this pin.
For example, we wrote a program that turns on / off the + 5V voltage with a 500 ms delay on the PB1 pin of the Attiny414 microcontroller. When the microcontroller is working properly, the connected LED will blink. Next we compile this program using by Atmel Studio 7 (in our case, “Build LED_414”). At the output we get the file of our program with the extension .hex. Project LED_414 can be downloaded here. The LED_414.hex file is located in this project in the Debug folder.
b) In the command line of the computer, run the pyupdi program using the pyupdi.py script. c) When the pyupdi.py script starts, it will ask you for the firmware settings, such as the microcontroller model, port number, baud rate, and firmware file with the .hex extension. In our case, this is the LED_414.hex file. The LED_414.hex file must be in the same directory as the pyupdi.py script, that is, in C: \ Users \ User. d) After setting the necessary parameters, we run pyupdi. The microcontroller is flashing by our file. After successful flashing, “Programming successful” appears in the console.
2 Preparation of the hardware part for the microcontroller programming process 2.1 We need a USB-TTL adapter. This adapter will be used by us as a programmer. The cost of this adapter is very small. However, this USB-TTL adapter (programmer) completely copes with its task. The adapter is built on the scheme PL2303HX.
Show price2.2 To build a circuit based on a microcontroller, we recommend using a solderless prototype board (breadboard). The prototype board will allow to save time for installation of the scheme. In addition, work with the scheme becomes very convenient.
Show price2.3 Attiny414 microcontroller can be mounted on a prototype board using by the SOP14 pitch 1.27 mm adapter. This adapter will also save time when assembling the circuit.
The connection diagram of the Attiny414 microcontroller to the programmer is presented below.
After installation, the final scheme with the LED looks like this.
The LED starts blinking after programming the Attiny414 microcontroller using by the LED_414.hex file.
Video of blinking LED connected to the Attiny414 microcontroller is shown below.
In conclusion, this article presents the algorithm for creating the program (firmware), the connection via the UPDI interface, the general connection scheme and the example of the Attiny414 microcontroller work. This article will be useful for working with Attiny 214/144/814 and Atmega microcontrollers with UPDI interface.
Your comments and suggestions will be waiting in the comments!