We connect the button to the ATtiny2313 microcontroller, a simple program. Programming attiny2313 Programming microcontrollers attiny2313

How to program ATtiny2313 microcontrollers? So, we have an ATtiny2313 microcontroller, an LPT port (necessarily an iron one - no USB-2-LPT works), several wires (no more than 10cm long) and of course a soldering iron. It is advisable to have a DB-25M connector (male), it will be more convenient to connect a microcontroller with it, but you can do without it. We solder the wires to pins 1, 10, 17, 18, 19, 20 of the microcontroller. We get something like what is in the photo:


I did it without a connector (only mothers were available...), and this is what happened:


True, my LPT port is placed on the table using a 1.5 meter long cable. But the cable must be shielded, otherwise there will be interference, interference and nothing will work. The diagram of this microcontroller programming device is like this:


To be completely honest, it is advisable to assemble the “correct” programmer. And then it will be easier and the port will be intact. I use STK200/300. Next we use the PonyProg2000 program. After starting the program, it will "neigh...." like a real pony. To stop hearing this again, check the “Disable sound” box in the window that appears. Click "OK". A window pops up saying that you need to calibrate the program. There are different types of computers, both slow and fast. Click "OK". Another window pops up - this tells us that we need to configure the interface (which programmer and where it is connected.). So go to the menu: Setup -> Calibration. In the window that appears:


Click "YES". A couple of seconds pass and the program says "Calibration OK". Next, go to the menu: Setup -> Interface Setup. In the window that appears, configure it as shown in the figure.


Now go to the menu: Command -> Program Options. In the window that appears, configure it as shown in the figure.


Everything is ready for programming!... So, the sequence of actions:


1. Select "AVR micro" from the list
2. From another list, select "ATtiny2313"
3. Load the firmware file (File -> Open Device File), select the desired file, for example “rm-1_full.hex”.
4. Click the “Launch program cycle” button. When programming is completed the program will say "Program successful"
5. And finally, you need to program the so-called Fuses. To do this, click the “Security and Configuration Bits” button. In the window that appears, click “Read”, then check the boxes and click “Write”.

ATTENTION! If you don't know what a particular configuration bit means, don't touch it. Now we have the ATtiny2313 controller ready for use! On the forum you can download the PonyProg2000 program and the original article with additional pictures. Material for the Radio Circuit website was provided by Ansel73.

So, we have an ATtiny2313 microcontroller, an LPT port (an iron port is required, no USB-2-LPT works), several wires (no more than 10 cm long) and, of course, a soldering iron. It is better to have a DB - 25M (male) connector; it will be much more convenient to connect the microcontroller with it, but you can do without it. Solder the wires to pins 1, 10, 17, 18, 19, 20 of your microcontroller. You will get something like this, as in the photo:

Then, if there is a DB-25M connector, then solder the wires to it in accordance with the table shown below. And if it’s missing, then just plug the wires into the connector on the computer.

Here they did it without a connector (only the mothers were at hand), and this is what came out of it:

Here the LPT port was brought to the table using a 1.5 m long cable. The cable must be shielded, otherwise there will be interference and interference and then nothing will work. The diagram of this microcontroller programming device looks like this:

It’s better, of course, to make a “correct” programmer, since it will be simpler and the port will be more intact. In this case, STK200/300 was used. Then you need the PonyProg2000 program. After the program starts, it will “neigh” just like a real pony :). To prevent this sound from straining your ears in the future, you need to check the “Disable sound” box in the window that appears. Click OK. A window will pop up indicating that the program needs to be calibrated. Computers are different, both slow and fast. Click OK. Another window will pop up, it says that you need to configure the interface (which programmer and where it is connected). So, now go to the menu: Setup -> Calibration. In the window that appears:

Click "YES". A couple of seconds will pass and the program will say “Calibration OK”. Then go to the menu: Setup -> Interface Setup. In the window that appears, configure as shown in the figure.

Now go to the menu: Command -> Program Options. In the window that appears, configure as shown in the figure.

Now you're ready for programming! So, the steps of action:

  1. Select "AVR micro" from the list
  2. From another list you need to select “ATtiny2313”
  3. Now download the firmware file (File -> Open Device File), select the desired file, for example “rm-1_full.hex”.
  4. Click the “Launch program cycle” button. When programming is finished the program will say “Program successful”
  5. And finally, you need to program the so-called Fuses. To do this, click the “Security and Configuration Bits” button. In the window that appears, click “Read”, then check the boxes and click “Write”.

    ATTENTION! If you don't know what a particular configuration bit means, then don't touch it. Now our ATtiny2313 controller is ready for work!

    This is all. All the best.

A simple experiment with connecting a button to an AVR microcontroller is described, and a simple C program for processing button presses is analyzed. Let's look at the features of connecting a button to the MK ports, as well as methods for reading button states in the C language.

Previous articles discussed experiments with LEDs that were connected to microcontroller ports configured for Output.

In this article, we will connect a button to the microcontroller, the contacts of which close when pressed, and open when released (closed button).

Schematic diagram of the experiment

In order to be able to at least somehow observe and control something using a button, we will connect two more LEDs to the microcontroller. The diagram is very simple, here it is:

Rice. 1. Schematic diagram of the experiment with the ATtiny2313 microcontroller and button.

As you can see, two LEDs are connected to two ports PB0 and PB1 through limiting resistors, and a button is connected to port PD2 and it also has a limiting resistor. To connect the programmer to the MK, the Conn 1 (AVR-ISP) connector is used, and to connect the circuit to a separate +5V power source, two contacts are used - P1 and P2.

Rice. 2. An experiment diagram with a microcontroller and a button assembled on a solderless breadboard.

It is important to note that for safe use of a port with a button, a resistor with a resistance of 1 KOhm is connected in series with it (you can also connect it to another resistance of 600 Ohms - 2 KOhms). Accept this as a rule of good manners when working with pins, which will protect the MK port from failure in the event of an erroneous high-level supply to the pin and when the button is closed.

Structure of I/O ports in AVR microcontrollers

The microcontroller pins are universal GPIO (General Purpose Input Output), you can connect both actuators (indicators, power switches) and various digital sensors (buttons, switches) to them.

Several pins in the MK can be connected to an ADC/DAC (Analog-to-Digital-Converter and vice versa), with their help you can analyze and generate analog signals. Conventional GPIOs cannot work with analog signals; they can only have 0 (0V) or 1 (+5V) at their input/output.

Each GPIO pin inside the microcontroller is connected to several blocks and electronic components that are useful to know about:

  • Between the port pin and each of the power rails (GND and VCC) connected via diode. They are used to “dampen” short-term interference, voltage surges relative to the pin and each of the power rails;
  • There is also a capacitor between the pin and GND. I don’t know exactly why it is needed, perhaps for protection against interference, to prevent contact bounce when using buttons and switches connected to a pin, or for something else;
  • Connected to each pin an electronic key with a resistor is a pull-up of the pin to the voltage of the power source (Pull-UP). This electronic key is turned on by software and serves to set the default high logical level 1 (+5V) when working with a pin in input mode (Input);
  • Between the pin and each of the power buses (GND and VCC) two more electronic switches (without resistors) are included; they are needed to set a high (+5V) or low (0V) logical level on the pin when the pin is operating in Output mode.

For software control and configuration of each of the ports, three special registers are used, for example for port “B”:

  • DDRB - register (8 bits) for setting the operating modes of pins - input or output. This is done by setting the corresponding bits in the register;
  • PORTB is a register for controlling the state of the port pins in output mode - high or low level. Also used in input mode, used to enable pull-up resistors and set the default input level high;
  • PINB is a register that contains the logical states of the pins on a port, used to read the values ​​of ports that are configured in input mode.

You can learn more about the design of ports for a specific microcontroller model from its datasheet, in the “I/O-Ports” section; there may also be examples of code in C and Assembly for working with ports.

RESET pin as I/O port

It is useful to know that the “RESET” pin of the microcircuit (in our diagram it is pin number 1), which is intended for resetting the execution of the microcontroller program (reboot), can also be used to connect buttons, LEDs and other input/output devices, that is, it can be turned into a regular GPIO.

This can be useful if the microcircuit does not have enough pins for your design. For example, when assembling some device on an ATtiny13 chip (8 pins, 2 pcs for power, 5 pcs for I/O ports, 1 pc for RESET), you found that one pin was missing for the LED. There may be several options to solve the problem:

  1. Reprogramming the RESET pin for an I/O port;
  2. Connecting an LED to one of the adjacent already used pins, using some histrosts in the circuit design and taking into account the possibility of its general use;
  3. Using another MK that has more pins, for example ATtiny2313.

Which of these options is simpler and cheaper in terms of finances/time - judge according to your own case.

To turn the "RESET" pin into an I/O port, you will have to change a special fuse - RSTDISBL (Reset Disable). But before you do this, you need to remember that after this operation, reprogramming the microcontroller will only be possible using a high-voltage programmer (12V); a regular USB ISP or another programmer powered by 5V will no longer be able to do its job.

C program

So, we have one button and two LEDs that are connected to the microcontroller, what can we do with them? - and we’ll do this (algorithm):

  1. After turning on the power, the LEDs will flash alternately and with a delay of 300 milliseconds;
  2. When you press and hold the button, only the blue LED will light;
  3. After releasing the button, the blue LED will flash 3 times with a delay of 500 milliseconds, after which the LEDs will flash alternately again with a delay of 300 milliseconds.

An example of the implementation of such an algorithm in C language under AVR is given below. Let's create a new file for our program and open it for editing:

Nano /tmp/avr-switch-test.c

Let's put the following code in the body of the file:

/* Experiment with a button on ATtiny2313 * https://site */ #define F_CPU 1000000UL // Core frequency = 1 MHz #include #include // -- Macros for controlling LEDs -- #define LED_BLUE_ON PORTB |= (1<< PB0) // Засвечиваем синий диод #define LED_BLUE_OFF PORTB &= ~(1 << PB0) // Гасим синий диод #define LED_RED_ON PORTB |= (1 << PB1) // Засвечиваем красный диод #define LED_RED_OFF PORTB &= ~(1 << PB1) // Гасим красный диод // Основная программа void main(void) { DDRD |= (0 << PD2); // Пин 6 - на вход PORTD |= (1 << PD2); // Включаем подтягивающий (Pull-UP) резистор для пина 6 DDRB |= (1 << PB0); // Пин 12 - на вывод DDRB |= (1 << PB1); // пин 13 - на вывод // -- Бесконечный цикл -- while(1) { _delay_ms(300); // Задержка 300 мс LED_BLUE_ON; // Включаем синий диод LED_RED_OFF; // Гасим красный диод _delay_ms(300); LED_RED_ON; // Включаем красный диод LED_BLUE_OFF; // Гасим синий диод if(!(PIND & (1 << PD2))) { // Проверяем нажата ли кнопка _delay_ms(50); // Задержка 50 мс (дребезг контактов) LED_RED_OFF; LED_BLUE_ON; while(!(PIND & (1 << PD2))); // Ждем пока кнопка не будет отпущена _delay_ms(500); // Дальше мигаем синим диодом LED_BLUE_OFF; _delay_ms(500); LED_BLUE_ON; _delay_ms(500); LED_BLUE_OFF; _delay_ms(500); LED_BLUE_ON; _delay_ms(500); LED_BLUE_OFF; _delay_ms(200); } // Конец блока работы с кнопкой } // Конец блока с вечным циклом }

First of all we ask constant F_CPU, which will indicate to the compiler the operating frequency of the microcontroller core; this is necessary for some subroutines and functions to work correctly. In our example, we use the time delay function - "_delay_ms" from the "util/delay.h" library, which calculates the time spent on idle cycles, based on the value in the F_CPU constant.

You can view the code of the "delay" library for organizing a time delay and which uses the F_CPU constant in GNU Linux using any text editor, for example, you can run the following command:

Nano /usr/lib/avr/include/util/delay.h

The factory set frequency of the internal RC oscillator in the ATtiny2313 microcontroller is 8000000Hz (8MHz), the frequency division fuse is also set by default - CKDIV8 (Clock Divide by 8), so the actual operating frequency of the crystal = 8000000Hz / 8 = 1000000Hz = 1MHz.

You can see what fuses are installed in the microcontroller using avrdude or a graphical shell for it called AVR8 Burn-O-Mat.

Further in the program, macros are defined to control the state of the ports to which the LEDs are connected: LED_BLUE_ON, LED_BLUE_OFF, LED_RED_ON, LED_RED_OFF. By calling a similar macro anywhere in the program, we can very easily turn on or turn off each of the LEDs, without having to repeat its code, which in turn will simplify the program and make it more visual.

In the main program "void main(void)" we start with the port configuration:

  • DDRD |= (0<< PD2) - установка разряда PD2 регистра DDRD на ввод, к нему подключена кнопка (пин 6);
  • PORTD |= (1<< PD2) - включение подтягивающего резистора для пина к которому привязан разряд PD2 регистра PORTD (пин 6);
  • DDRB |= (1<< PB0) - установка разряда PB0 в регистре DDRB на вывод, к нему подключен СИНИЙ светодиод (пин 12);
  • DDRB |= (1<< PB1) - установка разряда PB1 в регистре DDRB на вывод, к нему подключен КРАСНЫЙ светодиод (пин 13).

Next, using macros, we turn off the red LED and turn on the blue one. Now, using another eternal loop, but with a condition, we will wait until the button is released: "while(!(PIND & (1<< PD2)));".

When the button is released, a high level will appear on pin 6 (this will be done by the internal pull-up resistor that we turned on earlier), and logical 1 will be set in the PD2 bit of the PIND register.

After this, the blue LED flashes three times (on-off) with a delay of 0.5 seconds and the main eternal cycle starts working in a new way - two LEDs will light up alternately.

A very simple program, but nevertheless, it is a good example and grounds for further experiments.

Setting up Geany for ATtiny2313

In previous publications I conducted experiments with the ATMega8 microcontroller, but here I use a less “stuffed” MK - ATTiny2313.

To compile the program and flash it into the MK, you need to slightly reconfigure the commands for assembly in the Geany integrated programming environment.

Go to the Build menu - Set Build Commands. In the compilation command (C commands), you need to change the model of the chip used: "-mmcu=attiny2313". In the command to flash the MK, you need to change the chip type for avrdude: "-p t2313".

Rice. 3. Reconfiguring Geany to work with the ATTiny2313 microcontroller.

All commands are given for GNU Linux OS; if you have Windows, you may have to enter the full paths to the binary files “avr-gcc.exe”, “avr-objcopy.exe”, “avrdude.exe”.

I discussed in more detail how to configure Geany in GNU Linux in one of the previous articles in the series.

Compilation and firmware of the program in MK

Compiling, assembling and flashing the program can be done by clicking three buttons in turn in the Geany environment: “Compile”, “Build” and “Run”. Also, all these operations can be performed from the console, here are the commands for these actions (perform sequentially):

Avr-gcc -mmcu=attiny2313 -Os /tmp/avr-switch-test.c -o /tmp/avr-switch-test.o avr-objcopy -j .text -j .data -O ihex /tmp/avr- switch-test.o /tmp/avr-switch-test.hex avrdude -c usbasp -p t2313 -P usb -U flash:w:/tmp/avr-switch-test.hex

All commands are almost completely (with the exception of file name substitutions) identical to those that we corrected in the Geany settings.

Conclusion

Despite the simplicity of the experiment, I also tried to highlight some very important technical aspects of working with ports; the knowledge and experience provided will be useful in further study and work with ATMEL microcontrollers.

An example of how the programmer worksAVR ISP USB Lwith microcontrollerATtiny2313 A.

Introduction

AVR ISP USB L is a STK500 compatible programmer and is designed for programming (together with the AVR Studio program) all 8-bit microcontrollers with RISC architecture of the AVR series that have in-circuit programming capabilities (ISP interface).

Characteristics of AVR ISP USB L

Compatible with AVR Studio (AVR Studio 4.12 and later);

Supports all 8-bit AVR microcontrollers with in-circuit programming capability (ISP interface);

Support Flash and EEPROM programming;

Support programming configuration bits ( fuses) and lock bits;

Adjustable programming speed (1.2kHz, 4.0kHz, 57.6kHz, 115.2kHz, 460.8kHz and 1.845MHz SCK frequencies);

USB bus powered, no external power required;

Two processor supply voltages 3.3 V and 5.0 V (selectable by jumper);

Short circuit protection (self-resetting fuse), it is allowed to power the programmable microcontroller in a circuit that consumes no more than 50 mA.

Initial preparation for work

To get started with AVR ISP USB L, follow these steps:

    Install AVR Studio.

    Install the USB driver.

    Connect the AVR ISP USB L to the computer, the computer should detect and automatically

install new equipment.

    Using the device manager, determine the number of the virtual comport, which should be located in the aisles from (COM1) to (COM8). Renumber the comport if its number is higher than (COM8).

    Connect the microcontroller to the programmer (in this example it is ATtiny2313A-PU). The microcontroller is new and has never been programmed.

Beginning of work(checking connection with the programmer)

Launch AVR Studio and click the () button on the toolbar, this button allows you to select which programmer and communication port to connect to. Select STK500 (the in-circuit programmer AVR ISP USB L is command compatible with STK500) and

virtual comport, in this example it is (COM4). Press the button ( ) :

If the programmer is not found (this virtual port does not exist, the programmer is connected to another port, the programmer is not connected):

Attention! The programmer can only work with virtual ports from COM1 to COM8.

If the connection is successful, the following window will appear:

The programmer has been successfully connected, you can proceed directly to programming.

Microcontroller programming (reading signature bytes)

After successfully connecting the programmer and computer, let's check the connection with the microcontroller. The ATtiny2313A microcontroller must be connected to the programmer according to the diagram:

The presence of a quartz resonator is not necessary if you plan to operate from a built-in RC oscillator.

To check communication with the ATtiny2313A microcontroller, go to the (Main) tab.

The (Main) tab contains two groups of settings:

    Device and Signature Bytes

    Programming Mode and Target Settings

Device and Signature Bytes

This group contains two buttons:

Button (), when pressed, the selected device is completely erased. This erases the Flash and EEPROM, as well as the lock bits.

Button (), when pressed, the microcontroller signature byte is read.

Prgramming Mode and Target Settings (Programming mode and SCK signal frequency)

This group contains one button (), when clicked, a window for selecting the frequency of the SCK signal appears.

The new ATtiny2313A microcontroller has a clock frequency of 1 MHz, therefore, the SCK frequency should not be higher than 250 kHz. The closest suitable speed is 115.2 kHz. Of course, you can program at a SCK speed of 4 kHz, but then the programming process will be very long. Select the clock frequency of 115.2 kHz and press () to record the setting. The setting is saved in the non-volatile memory of the programmer:

This group also contains a list of programming modes; make sure that “ISP mode” is selected. “PP/HVSP mode” mode is not supported by this programmer:

To directly read signature bytes, select the desired microcontroller from the drop-down list, in our case it is ATtiny2313A:

Press the () button. If there is no connection with the microcontroller (incorrect connection), the “ISP Mode Error” window will appear:

The “ISP Mode Error” window may also appear if the SCK frequency is too high.

The frequency of the SCK signal must be four times lower than the clock frequency of the microcontroller!

If the signature byte is successfully read:

Directly bytes of the signature of the ATtiny2313A microcontroller (data from the documentation for the microcontroller):

0x000: 0x1E (Atmel manufacturer code).

0x001: 0x91 (Flash memory size 2KB).

0x002: 0x0A (this is the ATtiny2313/A microcontroller if byte 0x001 is 0x91).

The connection with the microcontroller is established, let's start programming the configuration bits.

Microcontroller programming (writing configuration bits)

The (Fuses) tab displays the configuration bits available for the selected microcontroller type (ATtiny2313A).

Configuration bits they call a special memory area (3 bytes) in AVR microcontrollers responsible for the initial (global) configuration. With these bits we indicate to the microcontroller which master oscillator it should work with (external / internal), divide the oscillator frequency by a factor or not, use the reset pin as a reset or as an additional I/O port, the amount of memory for the bootloader and much, much more. Each controller has its own set of configuration bits. All configuration bits are specified in the documentation for the microcontroller. From the factory, by default, the configuration bits are set for the microcontroller to operate from the internal master oscillator. There is no need to add anything, apply power, and it works. If you need to somehow change the operation of the microcontroller, for example, make it work from an external quartz resonator, you need to change the corresponding bits.

Please note that completely erasing the microcontroller ( ) does not affect configuration bits.

Description of the configuration bits of the ATtiny2313A microcontroller. The new microcontroller has the following settings:

Attention! Do not turn off the SPIEN bit. Turning this bit off will disable serial programming mode and the microcontroller will not respond.

Attention! Do not turn on the RSTDISBL bit. In serial programming mode, the RESET leg is required. Turning this bit on will turn off the RESET leg and the microcontroller will not respond.

Example configuration bit settings for our example:

BODLEVEL - 2.7 volts

CKDIV8 - disabled

When you have finished setting the settings, press the () button.

Successful programming ends with the message (field at the bottom of the tab):

After recording the settings, the microcontroller operates from an internal RC oscillator with a frequency of 8 MHz. The RESET response threshold is 2.7 volts.

Microcontroller programming (Flash and EEPROM firmware)

Before starting work, you need to download an example project in assembler (ATtiny2313A microcontroller) for AVR Studio. Link: TEST_ ATtiny2313 A_01. zip

Unpack the archive into a random folder or root directory. In this example it is D:\TEST_ATtiny2313A_01\

Attention! Folder and file names must be in Latin only.

To program Flash and EEPROM memory of the microcontroller, go to the (Program) tab.

On this tab we are interested in the following groups of settings:

Device(Device)

Flash(Program memory)

EEPROM(Non-volatile memory)

For direct programming, we indicate the path to *.hex and (if necessary) to *.eep files.

Next, press the button ( ), which is in the “Flash” group, if we want to program the Flash memory of the microcontroller.

In case of successful programming of the microcontroller's Flash memory:

Also, in case of a Flash programming error, a window appears (there is no connection with the microcontroller or the SCK frequency is too high):

To program the EEPROM, press the button ( ), which is located in the ”EEPROM” group.

In case of successful programming of the EEPROM memory of the microcontroller:

In case of programming error:

Also, in case of an EEPROM programming error, a window appears (there is no connection with the microcontroller or the SCK frequency is too high):

Additionally, on the (Program) tab there is a group of settings ( ELF Production File Format):

A file with the .elf extension can contain the contents of both FLASH and EEPROM, as well as configuration and lock bits. This format is convenient to use in production when you need to program a large number of microcontrollers with one firmware.

To create a *.elf file you need:

    Specify the path to the *.hex file.

    Specify the path to the *.eep file.

    Set and program configuration and security bits.

    Check the boxes.

Successful saving of the *.elf file ends with the message:

To program the microcontroller with an *.elf file, you need:

Microcontroller Programming (LockBits Write)

LockBits – designed to protect the Flash and EEPROM memory of the microcontroller from unauthorized reading. The security bits are programmed last. To read and program security bits, go to the tab (LockBits). The (LockBits) tab shows which program protection modes are available for selection for a given microcontroller type. The protection bits are read from the microcontroller and displayed:

In our case, three modes are available:

No memory lock features enabled”– security bits are not set.

Further programming disabled– programming of the microcontroller is prohibited, reading is allowed.

Further programming and verification disabled– programming and reading of the microcontroller is prohibited.

Once the “Further programming and verification disabled” protection level is enabled, it cannot be lowered by selecting a lower “Further programming disabled” protection level. The only way to remove set lock bits is to perform a full erase of the microcontroller, which also erases the Flash and EEPROM.

Additional features (read calibration byte)

The calibration byte contains a trim value that must be written to the OSCCAL register to adjust the frequency of the internal RC oscillator (if you plan to use it). The generator calibration byte is written to the microcontroller during production and cannot be erased or changed by the user.

    Oscillator Calibration Byte

This group contains:

To read the contents of the calibration byte, from the drop-down list, select the frequency of the RC oscillator 8 MHz and press ( ).

The value of the calibration byte is 0x60.

The value of the calibration byte is not available directly from the program. But using a programmer, you can write it to any memory cell of the microcontroller (Flash or EEPROM) and then read it from the program and write it to the OSCCAL register.

An example of writing a calibration byte to EEPROM at address 20 (decimal) for an 8 MHz RC oscillator.

From the drop-down list select ( ) RC oscillator frequency 8 MHz. In the “Address” text field, enter 20. Set the switch (). Press the () button.

Successful writing of the calibration byte ends with the message:

Additional features (Automatic mode)

To program multiple microcontrollers with the same firmware, tab ( Auto) offers a tool to automate the execution of a user-specified sequence of commands. The commands are listed in order of execution. To enable the command, select the appropriate checkbox.

After pressing the button (), the following sequence of operations will be performed:

“Erase Device” – erase the microcontroller.

“Program Flash” – program Flash memory.

“Verify Flash” – compare Flash and *.hex file.

“Program EEPROM” – program EEPROM memory.

“Verify EEPROM” – compare EEPROM and *.eep file.

“Program Fuses” – program configuration bits.

“Verify Fuses” – compare configuration bits (with previously set ones).

”Program lock bits” – program the security bits.

“Verify lock bits” – compare the security bits (with previously set ones).

Attention! For the first programmable microcontroller, you need to set the configuration bits and security bits.

If necessary, you can record the command execution log in a text file by including

checkbox()," Recording the protocol to a file". After checking the " Log to file" all output from commands will be written to a text file. The file is selected/created by pressing the button " Browse" ("Review") and selecting the location where it is placed or should be created. The output will be saved to this file and can later be viewed in a text editor.

Once configured, the same programming sequence will be executed each time the () button is pressed.

Additional tabs (HWSettings)

Tab (HW Settings) only for STK500 programmer.

Additional tabs (HWInfo)

The (HW Info) tab displays the firmware version of the programmer.

AVR RISC architecture:

RISC (Reduced Instruction Set Computer). This architecture has a large set of instructions, most of which are executed in 1 machine cycle. It follows that compared to previous microcontrollers based on CISC architecture (for example, MCS51), RISC microcontrollers are 12 times faster.

Or if we take a certain level of performance as a basis, then to fulfill this condition, microcontrollers based on RISC (Attiny2313) require 12 times less generator clock frequency, which leads to a significant reduction in power consumption. In this regard, it becomes possible to design various devices on the Attiny2313 using battery power.

Operational Storage Device (RAM) and non-volatile memory of data and programs:

  • 2 KB of self-programmable Flash program memory that can provide 10,000 write/erase repeats.
  • 128 Bytes of EEPROM writeable data memory that can provide 100,000 write/erase repeats.
  • 128 Bytes SRAM memory (read-only RAM).
  • It is possible to use the function to protect program code and EEPROM data.

Peripheral properties:

  1. Microcontroller Attiny2313 equipped with an eight-bit timer-counter with a separately installed prescaler with a maximum coefficient of 256.
  2. There is also a sixteen-bit timer-counter with a separate prescaler, capture and comparison circuit. The timer-counter can be clocked either from an external signal source or from an internal one.
  3. Two channels. There is an operating mode of fast PWM modulation and PWM with phase correction.
  4. Internal analog comparator.
  5. Watchdog timer (programmable) with internal oscillator.
  6. Serial Universal Interface (USI).

Special technical indicators of Attiny2313:


  • Idle— Idle mode. In this case, only the central processor stops working. Idle does not affect the operation of the SPI, analog comparator, A/D converter, counter timer, watchdog, or interrupt system. In fact, all that happens is that the synchronization of the CPU core and flash memory stops. The Attiny2313 microcontroller returns to normal operation from Idle mode by an external or internal interrupt.
  • Power-down— The most economical mode, in which the Attiny2313 microcontroller is actually switched off from power consumption. In this state, the clock generator stops and all peripherals are turned off. Only the interrupt processing module from an external source remains active. When an interrupt is detected, the Attiny2313 microcontroller exits Power-down and returns to normal operation.
  • Standby– the microcontroller switches to this power consumption standby mode using the SLEE command. This is similar to shutting down, the only difference being that the clock continues to run.

Input-output ports of the Attiny2313 microcontroller:

The microcontroller is equipped with 18 I/O pins, which can be programmed based on the needs that arise when designing a specific device. The output buffers of these ports can withstand a relatively high load.

  • Port A (PA2 - PA0) – 3 bits. Bidirectional I/O port with programmable pull-up resistors.
  • Port B (PB7 - PB0) – 8 bits. Bidirectional I/O port with programmable pull-up resistors.
  • Port D (PD6 - PD0) – 7 bits. Bidirectional I/O port with programmable pull-up resistors.

Supply voltage range:

The microcontroller operates successfully with a supply voltage from 1.8 to 5.5 volts. Current consumption depends on the operating mode of the controller:

Active mode:

  • 20 µA at a clock frequency of 32 kHz and a supply voltage of 1.8 volts.
  • 300 µA at a clock frequency of 1 MHz and a supply voltage of 1.8 volts.

Power Saving Mode:

  • 0.5 µA at a supply voltage of 1.8 volts.

(3.6 Mb, downloaded: 5,958)

Share with friends or save for yourself:

Loading...