Top
Home


Attiny2313 Microcontroller Programming with Arduino

Brief Introduction:

Attiny2313 is an AVR based High-performance and Low-power RISC type micro-controller. It has 20 pins. It has 2KiB or 4KiB Flash memory, 128bytes or 256bytes of SRAM,  128bytes or 256bytes of EEPROM, 8bit or 16bit timer clock, 1 x 4 PWM channel, and 18 GPIO pin. But there is no ADC channel. This micro-controller also supports UART, I2C, SPI communication (don't have any dedicated pin for communication, the GPIO pins are used for the communication).

 

Datasheet:

For more information check the datasheet of Attiny2313 micro-controller. 

 

Setup:

To program this microcontroller we need the help of another microcontroller, which will be used for the In-System-Programmer or ISP. This ISP is used to program AVR microcontrollers. Here we will use the very famous Arduino Uno board as ISP. So, first of all, we need to connect the Attiny2313 microcontroller to Arduino Uno. To do this we need some flexible wires. The connection should be like this-

Arduino Uno --------------> Attiny2313

      pin 13  ------------------> pin 19 (SCL)

      pin 12  ------------------> pin 18 (MISO)

      pin 11  ------------------> pin 17 (MOSI)

      pin 10 ------------------> pin 1 (RESET)

      VCC  ------------------> pin 20 (VCC)

      Ground ----------------> pin 10 (GND)

 

After connecting those pins we have to set up the software for the operation. The very useful and common software is the Arduino IDE. Download the latest Arduino IDE from Arduino official website arduino.cc. After download and install the IDE we need some modification for our operation. 

Download the tiny.zip library from here and unzip the library into the 'hardware' folder of the Arduino IDE. Then open the IDE and connect the Arduino Uno board by USB port. Then go the File > Examples > ArduinoISP and open the sketch, then simply select the board from Tool > Board > Arduino Uno, then select the port from Tool > Port > COM x. Then simply upload the sketch by upload button.

Select the ArduinoISP sketch

 

ArduinoISP sketch

 

 

 

Operation:

After successful setup now we have to burn the bootloader code ta a virgin Attiny2313 micro-controller. To do this first we select the board as Attiny2313 with 8MHz clock frequency. Then simply select the bootloader option form Tool > Burn Bootloader. Maybe it will take one or two minutes. 

After successfully burn the bootloader its time to upload the original code for the micro-controller. For testing purpose, you also can take a pre-written sketch from example, but before uploading the sketch we need to change the pin number according to this pic.

Here we use the Blink sketch from File > Examples > Basics > Blink. And change the default pin 13 to pin 6, which you find same in the next picture. And change the Programmer Module from Tool > Programmer > Arduino as ISP. 

 

 

Then upload the sketch from Sketch > Upload Using Programmer. It will upload the sketch to your micro-controller. Hope it will work properly.

 

 

If this small effort can help in your any project then my effort will be successful. Please put feedback On our contact page.

If you faced any problem please send an email to admin@arghyabiswas.com. Thanks for being with us.




Thank You

Leave a Comment







View Previous Comment

u retarded 26th Mar, 2021

There is no bootloader on the zip file you provide xD What are you thinking about??? lmao