Sunday, September 12, 2010

Bits on AVR

Memory
The ATMega memory consists of three parts:
● Data memory of SRAM : used for temporary storage of data values
● Program memory, which is a Flash Memory, that can be rewritten up to 10,000 times
● Finally the EEPROM memory, which is used for permanent storage of data values or initial parameters for the microcontroller.
In-System Programmable flash
--can easily program chips, even while in-circuit.
Many peripherals:
a whole bunch of internal and external interrupt sources and peripherals are available on a wide range of devices (timers, UARTs, ADC, watchdog,etc.).
32 registers:
The 32 working registers (all directly usable by the ALU) help keep performance snappy, reducing the use of time consuming RAM access.
Internal RC oscillators can be used on many chips to reduce part count further.
Flexible interrupt module with multiple internal/ external interrupt sources.
Multiple power saving modes.


Friday, September 10, 2010

AVR Microcontroller and C language




High Level Languages (HLLs) are rapidly becoming the standard methodology for

embedded microcontrollers due to improved time-to-market and simplified

maintenance support. In order to ensure that the new ATMEL AVR family of

microcontrollers was well suited as a target for C compiler, the external C compiler

development was started before the AVR architecture and instruction set were

completed. During the initial development of the C compiler, several potential

improvements in the AVR were identified and implemented. The result of this

cooperation between the compiler developer and the AVR development team is a

microcontroller for which highly efficient, high performance code is generated.



The AVR Microcontroller

The AVR enhanced RISC microcontrollers are based on a new RISC architecture

that has been developed to take advantage of semiconductor integration and software

capabilities of the 1990's. A block diagram of the AVR architecture is given in figure 1.

The memory sizes and peripherals indicated in the figure are for the AT90S8414

microcontroller.

Central in the AVR architecture is the fast-access RISC register file, which consists of

32 x 8-bit general purpose working registers. Within one single clock cycle, AVR can

feed two arbitrary registers from the register file to the ALU, do a requested operation,

and write back the result to an arbitrary register. The ALU supports arithmetic and

logic functions between registers or between a register and a constant. Single register

operations are also executed in the ALU.

As can be seen from the figure, AVR uses a Harvard architecture, where the program

memory space is separated from the data memory space. Program memory is accessed

with a single level pipelining. While one instruction is being executed, the next

instruction is being pre-fetched from the program memory.

Due to the true single cycle execution of arithmetic and logic operations, the AVR

microcontrollers achieve performance approaching 1 MIPS per MHz allowing the

system designer to optimize power consumption versus processing speed.







The Architecture allows for up to 8M Bytes program memory, and 16MBytes of Data

memory, and covers a wide range of applications.

Sunday, June 27, 2010

Types of AVR’s

AVRs are generally classified into four broad groups:
tinyAVR -- the ATtiny series
o 8-32-pin package
o 1-8 kB program memory
o Limited peripheral set
• megaAVR -- the ATmega series
o 28-100-pin package
o 4-256 kB program memory
o Extended instruction set (Multiply instructions and instructions for handling larger program memories)
o Extensive peripheral set
• XMEGA -- the ATxmega series
o 44-64-100-pin package (A4, A3, A1)
o 16-384 kB program memory
o Extended performance features, such as DMA, "Event System", and cryptography support.
o Extensive peripheral set with DACs
• Application specific AVR
o megaAVRs with special features not found on the other members of the AVR family, such as USB controller, LCD controller, advanced PWM, CAN etc.
o FPSLIC (Field Programmable System Level Integrated Circuit), an AVR core on-die with an FPGA. The FPSLIC uses SRAM for the AVR program code, unlike all other AVRs. Partly due to the relative speed difference between SRAM and flash, the AVR core in the FPSLIC can run at up to 50MHz.

What is an AVR?



The AVR family of microcontrollers are named after two Norvegian students (Alf-Egil Bogen and Vegard Wollan) who invented them. AVR stands for Alf and Vegard's Risc architecture. AVR that comes from Atmel are economical, feature-rich microcontrollers featuring flash program memory. The entire family shares the same instruction set and basic architecture, so you don't have to re-learn a new architecture when going from a small 8 pin part with 2K of program memory to a large pin part with 8K or more of program storage.
All AVR microcontrollers are in-system programmable through a serial interface. You can program the chip's flash program storage as well as EEPROM using simple software and just 4 wires to your target board. Easy in-circuit programmability combined with flash memory makes it easy to update code in the field or during development.
The AVR architecture was designed from the ground up for efficiency with C code. There are a number of C compilers available commercially and for free. You can also use the straightforward assembly language approach.
The AVR is a Modified Harvard architecture 8-bit RISC single chip microcontroller. It was developed by Atmel in 1996. Harvard architecture means that the program and data are stored in separate memory spaces which are accessible simultaneously. The AVR was one of the first microcontroller families to use on-chip flash memory for program storage, as opposed to One-Time Programmable ROM, EPROM, or EEPROM used by other microcontrollers at the time. Flash memory is a nonvolatile (persistent on power-down) programmable memory.
Low power and high performance AVR microcontrollers can handle demanding 8 and 16-bit applications. With a single cycle instruction RISC CPU, picoPower technology, and a rich feature set, the AVR architecture ensures easy application development and fast code execution combined with the lowest possible power consumption.
The well-defined I/O structure limits the need for external components and reduce development cost. A variety of timers, SPIs, UARTs, internal oscillators, pull-up resistors, pulse width modulation, Analog Comparators, ADCs and Watch-Dog Timers are some of the features available for engineers. It is interesting to note that most instructions only take a single clock cycle to execute and there is no internal clock division. Whether you program in C, Pascal or assembly language, the tuned AVR instructions decrease program size and development time. The AVR processor features a real life stack and its instruction set was designed and optimized for use with high level languages - it is easy to program these chips using C. AVR microcontrollers may be programmed using assembly or a higher level language. Learning to program it in assembly language is a good idea, as it gives you in depth understanding of the internal operations.
A comprehensive collection of application notes also kick-start problematic tasks. Since the introduction of the classic AT90S1200 device with on-chip in-system programmable Flash and EEPROM memory in 1997, today's large AVR microcontroller portfolio consists of devices sharing a single CPU architecture. This makes it easy to find the AVR microcontroller for almost any application.
Getting started with the AVR requires nothing more than the free assembler, a simple programmer such as the one by Jerry Meng, and a target board. The target board can be as simple as a few parts since the AVR is highly integrated. Since it is easy to reprogram the flash memory code space, you can develop code and test without the need for an expensive in-circuit emulator. Of course it is nice if you can afford it, but the AVR opens up the world of embedded control to those who could not afford the tools in the past. For under $20 you can be on your way.

Tuesday, June 22, 2010

What is a microcontroller....?

What is a microcontroller?

A micro consists of:

  • Flash ROM memory for holding your program, they call it non-volatile cause it will retain your program even when power goes off. Next time it powers up, your code will run again. However, it is electrically erasable so you may use your programmer to program it and re-program it and …
  • RAM memory for holding runtime data, say variables that change during execution and are not to be remembered forever, they will be lost when power goes off.
  • EEPROM non-volatile memory for those variables that are to be remembered when power goes off. You may access the micro's EEPROM either in advance when you program the micro or during runtime.
  • CPU/ALU the processing unit for doing arithmetic and logical operations amongst other things. Mainly these other things are controlling program flow (yes these ifs and fors you know from high level languages) but also for transferring data within the microcontroller.
  • Peripherals that are dedicated for various purposes, e.g the I/O ports are for turning pins on and off, USART is for communicating serially with another device (may be a PC), SPI is another serial protocol but for board level communication (short distance), interrupts are for getting external events asynchronously with our program flow, timers for measuring time, ADC for measuring analog quantities and the list goes on …
  • Registers hold 8-bit values and come into two flavors. Dedicated, which are used for configuring the operation of the micro and its peripherals. General purpose, working together with the ALU for storing temporarily results.
  • Clock is used by the micro for synchronizing all its operations. The clock is basically a train of square pulses at certain frequency, in our case 7.3728MHz. It is usually an external crystal, but one may use the internal clock.
AVRs are produced by ATMEL, you may go there and download the datasheet of a micro of AVR series, have a look at the application notes as well. Be careful not to be scared by the vast amount of information. We need only specific set of informations for each application.