Basic understanding of microcontroller interrupts

This tutorial is based on Atmega328 microcontroller, which is popular in Arduino boards. So you’ll be able to test all code examples on Arduino as it can serve as general purpose AVR test board with no problem. Understanding Interrupts Probably you won’t be able to find a microcontroller without interrupt capability. These are essential attributes of any modern microcontroller or processor. They may seem confusing and tricky at first glance, but during the time, you will find out that regular MCU operation is impossible without interrupts. Interrupts can be compared to real-life events. Look around – all your activities are full of them. For instance, you are reading this tutorial and find it interesting, so you are all in it. But suddenly, your cell phone rings. What do you do? You remember the last stroke you’ve read and answered the phone. One phone conversation is over; you return to your reading as if nothing happened. Well, this is only one example of interrupt to give some visual clue what interrupts are.

Continue reading

Setting up AVR development platform

You can be encouraged to use various types of AVR development tools. Most of them cost money to get full functionality and support. All they are great tools out of the box with fast support that you have to pay. Of course, you can give it a try with their limited versions to see capabilities. As we mentioned before, we will use free tools that are great enough compared to commercials. UPDATE! Here are the currently supported software options for AVR microcontroller development: WinAVR or AVR-GCC tools WinAVR is a toolset for C programming the AVR microcontrollers. It is a bunch of small programs that make development as comfortable as possible. The main tools are avr-gcc compiler, avrdude programmer, avr-gdb debugger, and more. These are command-line tools, so you need to integrate them into some integrated development environment (IDE). There can be any IDE supporting external tools like Eclipse and, of course AVRStudio that we will be using. Besides, WinAVR comes with great program writing tool – Programmers Notepad. Actually, with WinAVR, you can write, compile, upload to chip, and…

Continue reading

AVR at a glance

Any AVR microcontroller is an 8-bit computer in a chip designed and manufactured by ATMEL Corporation. It has some RAM and ROM (Flash) as well. There is also an EEPROM memory. Including AVR core CPU, all these are more than enough to say that it is a small computer where you can execute programs stored in Flash memory, run them while operating data in SRAM, and store some constant values in EEPROM. Compared to the actual computer that sits on your table, you can say that AVR core is a CPU like AMD or Pentium. Flash memory would be your hard drive where programs are stored; RAM is RAM nothing to add there. EEPROM can probably be compared to some media devices like CDRW. Anyway, this is only similitude in a different scale. AVR microcontrollers aren’t limited with core CPU and memory. The main thing that makes them valuable (and any other type of microcontroller) – they are rich in peripherals inside the chip. In most cases, you will find USART, I2C, SPI, ADC, Timers/Counters, and a bunch of I/O…

Continue reading

AVR audio spectrum monitor on graphical LCD

Running a Fast Fourier Transform (FFT) algorithm on an 8-bit microcontroller can be challenging. Here are a few reasons why: This is an original version of the previously posted AVR FFT analyzer. Chan developed it some time ago and is still a good reference for those willing to build or modify their own FFT analyzers.   On SG12232C graphical LCD, there are who parts displayed: waveform and spectrum. It looks fantastic and authentic when playing music. The program runs on AVR Atmega8 microcontroller clocked at maximum 16MHz frequency. The signal is passed through an 8th-order elliptic filter(anti-alias filter) implemented on MAX293. The hardest part of this project was implementing an FFT algorithm requiring lots of processing. But Chan has reached 9.6kHz sampling with 75Hz resolution, which is enough for visualization. Besides firmware author also provides fixed point FFT library optimized for Atmega microcontrollers so anyone can enjoy creating similar projects.

Continue reading