Building beginner’s microcontroller development board using ATTiny2313

This tutorial will talk about how to build a development board for the Atmel ATTiny2313 series microcontroller using minimal components. The board will support ISP (In-system Programming) using any supported programmer (e.g. AVRISP) and can also be used as standalone board once the code is burned into it. Using similar concepts, you can build identical boards for other microcontrollers in the series too (e.g. ATMega32). Consider it poor man’s board or a lazy man’s board…when you need to get only the basics to begin experimenting with the microcontroller.

The picture below is the board I built. It took me around 5 hours (this was my first such board).

ATTiny2313 Development Board

ATTiny2313 Development Board for Beginners

Whenever you build a board like this, you need to consider the following:

  1. Planning for soldering and board layout
  2. Enable support for ISP (In-System Programming)
  3. The frequency (or clock source selection)
  4. Power source
  5. Ports and pins that you will expose to connect to peripherals

The remainder of the section will deal with each option as a sub-section. Please note, the discussion is specific to ATTiny2313 (but as stated before, can be extended to any microcontroller in the series)

Planning for soldering and creating board layout

You will first need to get a few components as listed below:

  1. ATTiny2313
  2. 20-pin IC socket (we will solder the socket and then push the IC in the socket. Never solder the IC directly)
  3. Terminal Block, 2-pin (for power source)
  4. 1uF (or 0.33uF) de-coupling capacitor
  5. Tactile switch (push-switch)
  6. 10K resistor
  7. Between 12pF – 22pF capacitors (2 Nos.)
  8. Crystal. If you are planning to do RS-232 based communication, please ensure, the crystal is a multiple of 1.8432 (e.g. 3.686 MHz, 7.3728MHz). Keep the value between 3 MHz – 20MHz. If you are not planning to do RS-232 programming, then pick any crystal less than 20MHz.
  9. 10-pin FRC cable PCB connector (male type)
  10. Male and female breakaway headers
  11. A veroboard (or proto-board)

The picture below explains the placement of the various components on the board during the build. Notice, I am yet to solder the two capacitors next to the crystal.

Component Placement for ATTiny2313 Development Board

Component Placement for ATTiny2313 Development Board

At the center, is the big-black-bad Attiny2313 🙂

The very first thing you need to do is to plan the layout and the various connections on a piece of paper. There are some key decisions that you need to make in this phase. Here are the decisions I made:

  1. The board will not have its own power supply. An external regulated power supply will be required to run the processor on the board. Every decision has its pros and cons. The decision I took has the following advantages:
    • The board has less component count.
    • The board layout is simple.
    • You are focusing on the microprocessor circuit and other things do not clutter your mind J
    • Having a board like this, works in the long term. When you decide to connect multiple boards to build a larger system, you can have one single power supply to drive all boards.
  2. I’ll have a reset switch on the board. Just to ensure I can kill the processing in case something goes not as plan. I have never come across that situation, but giants in this space (from whom I have learnt something) always recommend having a reset switch. So I’ll go by their advice. If you come across or know more, do let me know.
  3. I will use only port B. The reason is that on Attiny2313, you get all the 8-bits only on port B (PB0…PB7). That way, I have at-least 8-bits on a single port to experiment. Also, again, it helps me to keep things simple.
  4. I planned to do some RS-232 based programming. RS-232 based programming requires that the PC and your micro-controller agree on a baud rate. This baud rate must be such that your clock frequency is cleanly divisible by a number to keep errors in the data transmission low. To ensure this, the microcontroller must be driven by an external crystal. I had an old crystal in my junk box of 3.6864 MHz. This is a multiple of 1.8432 (1.8432 * 2 = 3.6864). The number “1.8432” is called magic-number, simply because it pops-out from nowhere! Now consider this, if you want a baud rate of 9600, then 3.6864 MHz / 384 = 9600. So, the crystal was used instead of the internal clock.
  5. Because I plan to use RS-232 based programming, I’m also interested in Tx/Rx pins. So, the other pins that I’ll use are Pin-2 and Pin-3. There are no other pins that I’m using on this board. (Port B and Tx/Rx)
  6. Professional boards are available at cheap rates, allow you to program a variety of microcontrollers, however, I decided to add in-system programming support for my board too. That helps me in the following
    • I get to learn the pin connections for programming the controller.
    • To reprogram the board with my next project, I do not need to take the microcontroller out and plug it in a different board. Who knows, some James Bond somewhere would have destroyed all programmer boards just to stop Dr. Evil from creating the next world domination program on Attiny2313!
  7. I took the decision that ISP interface will not be directly hardwired to the microcontroller pins. Given the fact that ATTiny2313 pins play multiple roles under multiple circumstances, the same pins are used to program and also for I/O. In general, there is no harm in hard-wiring the ISP connections, however, I kept mine completely disconnected. To program, I must connect the jumpers. When the jumpers are not connected, you cannot program the IC.
  8. When the ISP device is attached to the board, it is capable of providing power, thus, the ISP Vcc was connected to the microcontroller Vcc. This means, that as long as the ISP is connected, you do not need an external power source (remember the terminal blocks)

Once all the crucial decisions are taken, first create a block diagram on a piece of paper (I created mine on a tissue paper 🙂 ). The diagram has been reproduced below:

Component Soldering and Placement Plan

Component Soldering and Placement Plan

The diagram above, outlines where am I going to place the components. The rectangle with circles in it, represent male headers which will act as jumpers. As stated before, jumpers will be connected only during programming. One key thing to note here is that Vcc and GND run across the length of the board. It’s a good idea to do so. That way, the power and ground are available from all points on the board. Also note, the ISP interface connects to Vcc and ground. This means, the board can be powered by ISP device when connected and you do not need additional power source (but do not run power hungry devices directly, you may fry the board and upstream devices).

Soldering the ISP connections

ISP Connection Pinout

ISP Connection Pinout

I do not have a RS232 port on my laptop. Most recent laptops would probably not have one. That is why, these days, many online shops offer a USB based programmer. I have an old AVRISP programmer from that works great will various AVR microcontrollers. The ISP pinout of the programmer I have is shown on the left.

The connections I made between the ISP socket pins are given on the right.

Microcontroller Pins for ISP Connection

ISP Socket Connections

The diagram on the right represents how I soldered the various pins. Please note, you must join pin 4,6,8 & 10 and connect them to ground. All of them. Also, as stated in the board layout, connect the Vcc and ground to the Vcc and ground on the board so that ISP power can drive very low power experiments and you do not need an external power supply.

ISP pins on the Microcontroller

ISP pins on the Microcontroller

The ISP socket pins connected to the microcontroller pins as given on the left.Actually, as stated before, I just connected the Vcc and Ground of the ISP socket to the Vcc and ground on the board. Other pins were simply connected to male-headers (see previous images for clarity), both for the ISP socket and the microcontroller. So, during programming, I would connect them with jumpers and once programmed, I would remove the jumpers.

The circuit connected with jumpers for programming looks like the one shown below (Picture taken before board was complete, notice the capacitors and other headers still not soldered). The red wires are jumpers that complete the connection from ISP socket to microcontroller pins:

Microcontroller board with jumpers

 Clock source selection

As mentioned before, I’m using a 3.686 MHz crystal to ensure I have very low error rate during RS-232 communication. The ATTiny2313 ships with internal clock source of 8 MHz which is divided by 8 to give you 1MHz clock. If you really need a stable clock, you should use an external crystal. See the datasheet for details on values supported for frequency.

Also, before you program, you must burn the fuses to instruct/inform the controller that you plan to use an external crystal. Again, please see the datasheet for correct fuse bits. I used AVR Studio’s GUI to fuse the bits. Its pretty simple that way. I also programmed the fuse bit to output the clock source on pin 6 (for Attiny2313). I did this so that I can check the output with my oscilloscope and ensure that the controller is indeed running on 3.6864 MHz (and my oscilloscope did show the clock frequency to be 3.6864 MHz !)

Microcontroller Clock - External Crystal

Microcontroller Clock - External Crystal

To ensure crystal works correctly, create connections as shown on the left.

Do not forget the capacitors. Earlier, I did not connect the capacitors and only the crystal was connected. There was no clock on pin-6 L

The datasheet for 2313 recommends to use 12-22 PF capacitors. I used 22pF capacitors and it works.

The power source

This subject is already covered in great details in earlier sections. Just to re-iterate, I’m using external power source and have provided terminal blocks (green cubes in picture) for external power source. Additionally, for very low current experiments ( less than 20mA) I’m extracting power from the ISP programmer.

Ports and pins exposed

I soldered a female header (8-pin) with pin-12 till pin-19. That gives me access to all 8-bits of PortB.

I also soldered another femal header(2-pin) with pin-2 and pin-3 to gain access to Tx/Rx pins on the controller.

I could have used male-headers, like in professional boards, however, I did the other way round…simply because, I can push a single-stand wire (or breadboard wire) in the female connector much easily and connect additional circuit built on my breadboard.

Try out at your own risk…don’t hold me responsible for anything bad…Enjoy!


15 thoughts on “Building beginner’s microcontroller development board using ATTiny2313

  1. Pingback: Controlling DC Motors using AVR Microcontrollers « Vishnu's Blogs

  2. Pingback: How to build your first mobile robot platform « Vishnu's Blogs

  3. hi
    I am divya ,actually i have a doubt if i have a development board with atmega controller is it not possible to replace the atmega which is 28 pin with attiny2313a which is 20 pin s it not possible ?

    or simply i have to built another development kit?

    please do reply i am quite tensed because i have bought that kit of atmega development board

    • Divya,
      I’m not sure what are you trying to do. If you already have the Atmega (28 pin) development board, you do not need to create any other board for programming. You should be able to use your own development board. You should have a programmer with the development board and you should be able to use AVR Studio to program it. Tell me the details of which board you have and I should be able to tell you better.

  4. Hi
    Actually we our developing a project which is “usb protocol implementatiom on attiny 2313a” for which we need to design a development board for attiny2313a , I have seen components but can you tell me why you using are using that specific crystal only.

    I mean while desinging development board how to choose components.

    can you also suggest me how to implement these protocols into that controller.
    can you suggest any link which can explain in detail how usb works ,and how to implenet the protocol.

    I hope you will reply

  5. i want to know did u write any program in controllet attiny 2313a
    if u did ,what studio u have used and how to write the program and how to use programmer and which software u have used/

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s