Microcontrollers without interrupts are almost worthless. Interrupt is called what interrupts normal program flow. Interrupts are nothing more than subroutines that put on hold normal program flow while they are executed. After interrupt subroutines are finished they return to normal from last point. Those subroutines are called interrupt handlers that are called by some event like toggle external pin or some register value overfilled like timer overflow and so on. Why interrupts are so important? For instance without interrupts you would have to do loops in order to check if one or another event occurred. This operation is called polling. But pooling has many disadvantages like program have do loops taking resources from other task may be done. This is why microcontroller comes with multiple interrupt sources. Instead of checking events microcontroller has ability to interrupt normal program flow on event and jump to interrupt service subroutine and then get back to normal program flow.
VMLAB is one of well known free simulators that support AVR microcontrollers. You may get free version of VMLAB tools from amctools. The simulation is done not in real time as computer resources wouldn’t allow this, but all timings of processes viewed in virtual oscilloscope are tied to real world values.
VMLAB is a project workspace where special scripting language describes the initial conditionas and circuit showing to virtual simulator connections between hardware and microcontroller. Few pre-built examples you may find in folders C:\VMLAB\AVR_demo and C:\VMLAB\ WinAVRdemo (for default installation in C:\VMLAB\ folder).
VMLAB quite rich in its hardware support: Resistors, Grounded capacitors, Interactive switches / keys, LED diodes, Pulsed voltage source, Sine wave voltage source, Slider dependent voltage source (interactive), Non-ruturn-to-zero (NRZ) generator (interactive), Operational amplifier, Comparator, 2 inputs NAND gate, 8 bits D to A converter, RS232 based TTY (interactive), LCD module, I2C monitor (interactive), Interactive keypad 4x4 Multiprocess-dedicated: External Input, External Output. Actually you can do a wide range of simulations with your virtual embedded system before taking it to the real world. VMLAB also has a powerful scope feature where you can view voltages on pins or even some internal microcontroller register values like ACO, TIMOVF.
AVR microcontrollers like many any other Harvard architecture MCU's are ships with some amount of EEPROM (Electronically Erasable Read-Only memory ) memory. This type of memory allows developers to store program parameters, constants, menu strings etc. EEPROM memory is good that you can read like one byte and store modified, while FLASH memory usually is written in pages.
In this article I am going to show how to store data to EEPROM by defining a particular variable types.
Because AVR microcontrollers are Harvard architecture they have separate address spaces for different memory types: SRAM, FLASH and EEPROM. Each of these memories have their own purposes. If data will not change during all time of program execution, then it should be stored as one type of memory like EEPROM otherwise if data will be used frequently and will change during program execution, then it should be stored in SRAM memory. Where to store data decides program developer. One thing you should note, that working with different types of memories require different operations how they are accessed.
Usually when define variables in C language like int a – compiler automatically stores it in to the SRAM. But if you want you can place constants in EEPROM or even FLASH memories.
As I mentioned no specific operations aren't needed to work with variables sored in SRAM. Lets go through other two memory types FLASH and EEPROM.