admin - Wed, 10/25/2006 - 21:18
For this tutorial I have decided to add this Piconomic development board. You can purchase the board if you are from a South Africa.
Otherwise you can build this board by yourself. Piconomic allow to build a development board for non commercial personal use using their Protel 99 SE project files. Download Schematic to view it.
So I made one and now it is good chance to do some C programming by using it.
admin - Mon, 10/16/2006 - 13:27
AVR 16 bit timer is more advanced timer than 8 bit timer. It has more features and this allows more accurate program execution timing. 16 bit timer is used when precise signal generation or signal timing measurement needed. As 8 bit timer counter can calculate up to 225 counts the 16 bit timer counter maximum value may reach 65535. In AVR microcontrollers 16 bit timer is Timer1. It contains a 16 bit input capture register (ICR1) and two 16 bit output compare registers (OCR1A and OCR1B). Of course the timer counters register (TCNT1) which is 16 bit long. When programming is ASM language there is special procedure for accessing it (refer to datasheet). While in C language it is done automatically we won’t get to deep into this. Timer1 is controlled by two timer counter control registers (TCCR1A/B). Signals are visible at timer interrupt flag register (TIFR) and interrupts can be individually masked in timer interrupt mask register (TIMSK).
admin - Wed, 10/11/2006 - 13:00
AVR ATmaga8 Timer/Counter2 is little more advanced timer counter than Counter0 as it includes more features like:
Single Channel Counter
Clear Timer on Compare Match (Auto Reload)
Glitch-free, phase Correct Pulse Width Modulator (PWM)
10-bit Clock Pre-scaler
Overflow and Compare Match Interrupt Sources (TOV2 and OCF2)
Allows Clocking from External 32 kHz Watch Crystal Independent of the I/O Clock
So we have there another register included OCR2, which is used to compare timer counter register TCNT2 register value and react on compare match. Wee see that there is Auto-reload ability what means that timer can be cleared automatically on compare match.
admin - Wed, 10/11/2006 - 10:29
Timers are very important part of embedded systems. Timers can make your life much easier if used properly. Basically one good thing is that timers runs independently to main program flow. You just set up the timer and let it do its job while your main program may run and do its job. Timers are really easy to use. I will go through Atmega8 timers. Other AVR microcontroller models have similar timers. In this thread we will go through AVR 8 bit timers.
Atmega8 has two 8 bit timers/counters and one 16-bit timer counter with various abilities.
admin - Tue, 10/10/2006 - 10:40
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.
admin - Thu, 10/05/2006 - 14:37
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.
admin - Wed, 10/04/2006 - 08:57
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.
admin - Wed, 10/04/2006 - 08:04
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.
admin - Thu, 09/14/2006 - 06:46
I am sure- typecasting is one of common practices in embedded C when converting one variable to another. As AVR microcontrollers are 8 bit systems and sometimes we operate with 16, 32 or even 64 bit length variables we have an ability to change like 16 bit integer value to 8 bit char and so on. This operations is so called typecasting. So it is important to understand this operation in order to use it properly and get desired result.
admin - Thu, 09/14/2006 - 06:19
This is similar to #define preprocessor where you can describe a set of constatnts. Using preprocessor we use:
#define zero 0
#define one 1
#define two 3
But there is an alternative of using enumerating using keyword enum:
enum (zero=0,one, two); //zero=0, one=1; two=2
By default enumeration assigns values from 0 and up.
Now you can use enumeration like in following example: