Advertisement
diy attiny2313 development board cirucuit

ATtiny2313 Minimum DIY Development Board

This article shows you how to build your own ATtiny2313 microcontroller minimum development board in an inexpensive way. The ATtiny2313 microcontroller is a small, economical, yet powerful microcontroller convenient for running many little – to – complex level microcontroller programs.

ATtiny2313

The ATtiny2313 microcontroller has three ports (A, B and D) connected to 18 external pins on the ATtiny2313 package. These eighteen pins, plus two power supply pins (VCC and GND) cooked up the 20-pin ATtiny2313 microcontroller chip.

attiny2313 pinout

Each port of ATtiny2313 has its own set of registers (port registers) for controlling it. The port registers are accessed in software and data written to the registers will configure the pins of the port as input pins or output pins or whether the pins are connected to one of the internal peripheral devices of the ATtiny2313. Note that, each port has a set of three registers for controlling its pins as inputs / outputs (I/O):

  • DDR register: Data direction register (Configures the pin as input or output)
  • PORT register: Data register (When pin is configured as output, writing to this register will drive the pin high or low. When pin is configured as input, writing to this register will enable / disable the internal pullup resistor on the pin)
  • PIN register: Input pins address (Reading this register will give the 0 or 1 state of the pins of the port)

The Hardware

diy attiny2313 development board cirucuit

As schematic diagram shows, the hardware is very simple and can easily be constructed on a small piece of perforated prototyping board. All components, including the usb socket, can be fitted on the board. The development board can be powered from a usb port, or from an external dc power supply source. The software running in the ATtiny2313, described in the next section, is included for quick testing of the minimum development board. The ATtiny2313 microcontroller can be programmed using any of the AVR programming adaptors available.

(Proof of Concept – Initial testing of the idea)

(Proof of Concept – Initial testing of the idea)

The Software

The demo code is used to drive a visual indicator, interfaced with PB0 of the ATtiny2313 in a current sinking configuration. Here, the heartbeat indicator is nothing but a small LED. The little code sets up pin PB0 as output by configuring the corresponding bit in the DDR register for port B (DDRB register). After setting up the output pin, the code execution drops into a continuous while loop. In the loop, the LED is switched on and off by writing either a 1 or 0 to the corresponding bit in the PORT register for the B port (PORTB register).

The demo code is shown below. It is recommended to use ‘AVR Studio 4’ to handle the rest of the ‘build and burn’ process. The requisite steps are shown at the end of this article.

#include <avr/io.h>
void Delay(void);
int main(void)
{
    DDRB |= 1 << PB0;
    while(1)
    {
        PORTB &= ~(1 << PB0);
        Delay();
        PORTB |= 1 << PB0;
        Delay();
    }
}
void Delay(void)
{
    volatile unsigned int del = 16000;
    while(del--);
}

Why this demo code?

The demo code is deliberately included here to make the showcasing of ATtiny2313 Minimum Development Board as easy as possible, because a blinking lamp in the board is a trustworthy indication. Anyway, the user is free to feed suitable codes into the microcontroller through the ISP interface, and this will expedite the overall development process. For those looking for commercial production of this development board, an SMD version is preferred because of its compactness. Note that until you write fuse bits for external oscillator, by default ATtiny2313 runs on 1MHz (8MHz/8) calibrated internal RC oscillator. That is why no external Xtal is used here.

µC Programming Tips

Fig 3

  • Open AVR Studio
  • In the “Create new project” window, click on “AVR GCC”, add the “Project name”: “Attiny2313demo” and set the “Location” to a convenient spot, then click “Next
  • Choose “AVR simulator” as “Debug” Platform and “ATtiny2313” as device in device list, then click “Finish”
  • Paste the demo code in centre code window, compile the program by clicking on “Build” button (or by pressing shortcut key F7)
  • After a successful build, go to the project folder to find a folder named “ Default” inside it. Open the folder to view the “Hex” (Attiny2313demo.hex) file . Open this file to view the hex code (hexadecimal machine code of the program). Now you only need to burn this code into the ATtiny2313 microcontroller in the minimum development board. Just connect the output of the programmer to the respective ISP header pins of the unpowered ATtiny2313 minimum development board, and start flashing
  • Now remove the programmer, power the board from an external 5VDC power supply, and watch the LED. If everything is okay, you can find a flashing LED!

2 Comments

Join the conversation!

Error! Please fill all fields.
Looking for the latest from TI?