Thursday, July 12, 2007

Tiny AVR Microcontroller Runs on a Fruit Battery



Some of the fruit and vegetables we eat can be used to make electricity. The electrolytes in many fruit and vegetables, together with electrodes made of various metals can be used to make primary cells. One of the most easily available vegetable, the ubiquitous lemon can be used to make a fruit cell together with copper and zinc electrodes. The terminal voltage produced by such a cell is about 0.9V. The amount of current produced by such a cell depends on the surface area of the electrodes in contact with the electrolyte as well as the quality/type of electrolyte.

The AVR microcontroller is a leading low power microcontroller that has been around for almost a decade now. Recently, new lower power devices have been added to the AVR family, called the PicoPower AVR microcontrollers.

In this instructable, we show how even the regular AVR devices can be set up and programmed to run off a fruit battery.

from http://www.instructables.com/id/E6YDE8F5VZEZR7CUOI

Saturday, July 7, 2007

AVR Architecture



In order to maximize performance and parallelism, the AVR uses a Harvard architecture with separate memories and buses for program and data. Instructions in the program memory are executed with a single level pipelining. While one instruction is being executed, the next instruction is pre-fetched from the program memory. This concept enables instructions to be executed in every clock cycle. The program memory is In-System Reprogrammable Flash memory.

The fast-access Register File contains 32 x 8-bit general purpose working registers with a single clock cycle access time. This allows single-cycle Arithmetic Logic Unit (ALU) operation. In a typical ALU operation, two operands are output from the Register File, the operation is executed, and the result is stored back in the Register File – in one clock cycle.

Six of the 32 registers can be used as three 16-bit indirect address register pointers for Data Space addressing – enabling efficient address calculations. One of the these address pointers can also be used as an address pointer for look up tables in Flash Program memory. These added function registers are the 16-bit X-, Y-, and Z-register.

The ALU supports arithmetic and logic operations between registers or between a constant and a register. Single register operations can also be executed in the ALU. After an arithmetic operation, the Status Register is updated to reflect information about the result of the operation.

Program flow is provided by conditional and unconditional jump and call instructions, able to directly address the whole address space. Most AVR instructions have a single 16-bit word format. Every program memory address contains a 16- or 32-bit instruction.

Program Flash memory space is divided in two sections, the Boot program section and the Application Program section. Both sections have dedicated Lock bits for write and read/write protection. The SPM instruction that writes into the Application Flash memory section must reside in the Boot Program section.

During interrupts and subroutine calls, the return address Program Counter (PC) is stored on the Stack. The Stack is effectively allocated in the general data SRAM, and consequently the Stack size is only limited by the total SRAM size and the usage of the SRAM. All user programs must initialize the SP in the reset routine (before subroutines or interrupts are executed). The Stack Pointer SP is read/write accessible in the I/O space. The data SRAM can easily be accessed through the five different addressing modes supported in the AVR architecture.

The memory spaces in the AVR architecture are all linear and regular memory maps.

A flexible interrupt module has its control registers in the I/O space with an additional global interrupt enable bit in the Status Register. All interrupts have a separate interrupt vector in the interrupt vector table. The interrupts have priority in accordance with their interrupt vector position. The lower the interrupt vector address, the higher the priority.

The I/O memory space contains 64 addresses for CPU peripheral functions as Control Registers, SPI, and other I/O functions. The I/O Memory can be accessed directly, or as the Data Space locations following those of the Register File, $20 - $5F.

Why AVR microcontroller?

Whether a particular requirement needs to be implemented using discrete ICs or PLDs or
a microprocessor must be determined by the designer. However, many applications could
be suitably implemented using microcontrollers, and a great many of them would benefit
from using the AVR as outlined briefly below.
Atmel's AVR RISC family of controllers has the following features:
1. RISC architecture with mostly fixed-length instruction, load-store memory access,
and 32 general-purpose registers.
2. A two-stage instruction pipeline that speeds up execution.
3. Majority of instructions take one clock cycle.
4. Up to 10-MHz clock operation.
5. Wide variety of on-chip peripherals, including digital I/O, ADC, EEPROM, Timer,
UART, RTC timer, pulse width modulator (PWM), etc.
6. Internal program and data memory.
7. In-system programmable.
8. Available in 8-pin to 64-pin package size to suit wide variety of applications.
9. Up to 12 times performance speedup over conventional CISC controllers.
10. Wide operating voltage from 2.7 V to 6.0 V.
11. A simple architecture offers a small learning curve to the uninitiated.
What does the name AVR stand for? Atmel says that it is just a name. However, AVR
seems to have the initials of the people who designed the controller.