Transcript

31st Jan to 1st Feb 2008

TECHNOLOGY ROBOTICS SOCIETY

Indian Institute of Technology, Kharagpur

AVR Family of Microcontrollers 8-bit RISC Architecture, single cycle

instructions Principle features include

Internal oscillators, timers, UART, SPI, PWM generation, ADC, analog comparator and more…

Amenability to C programming In-System-Programmable (ISP) Flash Memory

http://www.atmel.com/products/AVR/

ATmega8 – AVR Family Member Up to 16 MIPS throughput 8KB ISP Flash Memory, 1KB SRAM, 512Byte

EEPROM 8bit / 16bit timers / counters Three PWM channels 8 Channel 10 bit ADC, Analog Comparator Programmable UART, SPI, TWI

ATmega8 – PDIP Package

ATmega8 – TQFP Package

ISP Flash Memory ISP : In-System-Programmable Flash

ROM No need of specialized programmer

hardware No need to remove processor from

circuit for reprogramming

STK200 ISP Dongle

PonyProg Programming Software http://www.lancos.com/prog.html

WinAVR WinAVR is a open source software

development suite for Atmel AVR series of RISC microcontrollers

GUI Integrated Development Environment Includes the GNU GCC compiler for C and

C++. http://winavr.sourceforge.net/

WinAVR IDE Screenshot

Procyon AVRlib AVRlib is a library of easy-to-use C functions

for AVR controllers AVRlib aims to allow programmers to work

quickly towards their end goal by reducing the time needed to write basic support functions and code

http://www.procyonengineering.com/avr/avrlib/

PWM DC Motor Control//Dual 8-bit PWM mode setup of timer 1

timer1PWMInit (8);

// Frequency Prescaling to F_CPU_CLOCK / 256

timer1SetPrescaler (4);

// Left and right motor speed set

timer1PWMASet (lSpeed); // Pin 15 (OC1A)

timer1PWMBSet (rSpeed); // Pin 16 (OC1B)

// Start on the PWM generation

timer1PWMAOn ();

timer1PWMBOn ();

ADC’s & Analog ComparatorDDRA = 0x00; // Configure Port A (ADC) as Input

PORTA = 0x00;// Disable internal pull up resistors

// Initialize Analog to Digital Converter

a2dInit();

// Set conversion speed

a2dSetPrescaler(ADC_PRESCALE_DIV32);

// Set analog voltage reference

a2dSetReference(ADC_REFERENCE_AVCC);

// Acquire analog data into digital format

for (i = 0; i < 8; i ++)

adcData [i] = a2dConvert8bit(i);

UART - Serial Communication// Initialize UART at 2400 bps

uartInit();

uartSetBaudRate (2400);

// Check is data received

if (!uartReceiveBufferIsEmpty ())

{

// if data received then get it in a variable

uartReceiveByte (&dataIn);

// do whatever u wish with dataIn

}

Crystal Oscillator Clock Source

AVR Fuse settingsCKOPT CKSEL3:0 Frequency

(MHz)C1 & C2

1 1010 0.4 – 0.9 -

1 1101 0.9 – 3.0 12 – 22 pf

1 1111 3.0 – 8.0 12 – 22 pf

0 1011, 1101, 1111

>= 1.0 12 – 22 pf

SUT 1:0 = 11

top related