Programacion de avr en c

Páginas: 5 (1079 palabras) Publicado: 20 de mayo de 2011
Programming ATMEL AVR series microcontrollers

Prof. Prabhat Ranjan (prabhat_ranjan@da-iict.org) DA-IICT, Gandhinagar

Outline
➲ ➲ ➲ ➲ ➲ ➲ ➲ ➲ ➲

AVR advantage Features of ATMega32 Microcontroller Memory AVR Registers Required software components Compiling and linking using avr-gcc Converting to Hex format Function register access Example Programs : (flashing LED, interrupt driven LED,binary counter)

AVR advantages




➲ ➲

Micro-controllers will often allow an optimal solution, combining complex functionality with reduced part count ATMEL AVR chips pack lots of power (1 MIPS/MHz, clocks up to 16MHz) and space (up to 128K of flash program memory and 4K of EEPROM and SRAM) at low prices. HLL Support, like C, helps increase reuse and reduce turn-around/debugtime/headaches. 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 oftimeconsuming 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.

ATMega32 : Features
● ● ● ● ● ● ● ● ● ● ● ● ●

32Kbytes Flash Program Memory 2Kbyte Internal SRAM 1024 Bytes EEPROM 2 x 8-Bit Timer/Counters and 1 x 16-Bit Timer/Counter FourPWM Channels 8 Channel 10-Bit ADC Programmable Serial USART Master / Slave SPI Interface Programmable Watchdog Timer 32 Programmable I/O Lines On-chip Analog Comparator Six Sleep Modes for Current Consumption Minimization Programmable Lock for Program Security

Microcontroller Memory


The ATMega memory consists of three parts:
● ● ●

Data memory of SRAM : used for temporary storage ofdata 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.

Flash Memory


The boot flash section, is for the bootloader program, which can be used to program the flash memory by using the on-board UART on the microcontroller ATMega32 Pinout




The ATMega32 has 4 ports, these are defined as PORTA, PORTB, PORTC and PORTD. Each of the port pins can be used for simple I/O, and in some cases contain a dual function for a peripheral function within the microcontroller.

AVR Registers


➲ ➲ ➲

All information in the microcontroller, from the program memory, the timer information, to the state on any of input oroutput pins, is stored in registers The 32 IO pins of the ATMega32 are divided into 4 ports, A, B, C, and D. Each port has 3 associated registers. For example, for port D, these registers are referred to in C-language by PORTD, PIND, and DDRD

The DDRx Register




The DDRD register sets the direction of Port D. Each bit of the DDRD register sets the corresponding Port D pin to be eitheran input or an output. A 1 makes the corresponding pin an output, and a 0 makes the corresponding pin an input
● ●

DDRD=0xF0; Port D : (Pin 0 – 3 ) - Input (Pin 4 -7 ) - Output

The PORTx Register


The PORTx register functions differently depending on whether a pin is set to input or output. The simpler case is if a pin is set to output. Then, the PORTC register, for example, controlsthe value at the physical IO pins on Port C
● ●

DDRC = 0xFF; //Set all Port C pins to output PORTC = 0xF0; //Set first 4 pins of Port C low and next 4 pins high

The PINx Register


When a pin is set to input, the PINx register contains the value applied to the pin


foo = PIND; //Store value of Port D Pins in foo





There is also a function available for checking the...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • programación c++
  • programacion C
  • Programacion c++
  • c# Programacion
  • Programacion En C#
  • Programacion en c
  • Programacion en c#
  • Programacion C++

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS