When interfacing microcontroller to outside world we often need to make Analog/Digital conversions (ADC). In this example, we will make 5 ADC inputs scanning that is driven by interrupt. Data are placed in results buffer and sent to UART by using functions for conversion of integer value to string.
When writing firmware for microcontroller often there is need to have constants or constant arrays. For example, to have fixed value to compare with measurement from ADC. If this value changes during program execution then it must be defined as variable and placed in RAM or EEPROM, but if it is fixed then it is better to place it in FLASH memory. Main reason why it is better to place it in FLASH is because it is biggest memory space in microcontroller and often we do not have enough RAM for project. Also, when writing predefined strings for sending to UART as messages for user, it is best to declare these strings as constants.
When communicating with other devices, we often need to parse incoming data stream to recognize predefined format of commands, for example, when using GPRS modem or GPS receiver. There are many examples when data stream parsing is a must have! In previous articles we have seen how to define strings (these will be predefined commands) in FLASH memory space and in that way save RAM memory for variables.
Now we will show how to detect when useful information have been received and extract received data.
When writing a program for microcontroller (also often called firmware) it is very useful to have communication with microcontroller. In this way you can give command and get feedback from microcontroller about current state and readings. This can be done by several integrated peripherals that are used for communication. One is especially convenient because every PC has serial port and that peripheral is UART (Universal Asynchronous Receiver Transmitter). It is asynchronous communication and basic configuration that is most often used needs only two pins. These are TX and RX.
Tutorials of how to drive input/output pins of AVR microcontroller are placed here. GPIO pin you need for every microcontroller for interaction with outside world. Detailed description of register usage with example code writen for codevision AVR compiler is placed here for you to download, test and learn thru examples.
General talk about AVR microcontrollers. Here is description of this microcontroller family. Discussion on what compiler to use and why. Basic steps what you need to start programming microcontrollers. This is starting point when you did not work with AVR before. It will guide you thru simple examples from basic steps to advanced level programming.
Fuses are an extremely important part programming a chip, but are rarely explained thoroughly. You only need to set them once, but if you don't do it right, it's a disaster! Here you will get all needed information on how to correctly program fuse bits.
Articles explainin usage ir Uart and practical examples will be places in this category
AVR Analog/Digital converter ADC
Examples on AVR ADC module usage in various modes will be placed here.
Using PWM with microcontroller s often needed in projects. Whether you want finecontroll of electromotor speed, or you want to change intensity of Led lamp or you simply need analog output and do not want to buy expensive Digital/Analog converter (DAC) PWM is ideal solution. In this category we will place examples that show how to configure and change parameters of PWM output on AVR microcontroller.
AVR external interrupts
When reading pin state it is often needed to react very fast on pin state change.
For this purpose external interrupt is used. External interrupt occurs when dedicated pin changes state. It can be triggered on rising, falling, or both edges of signal state. Here are placed examples that use external interrupt of AVR microcontroller.