avr projects

Getting started with atmel avr microcontrollers


Edsard Boelen, 16 march 2008
Some colleagues of mine are building devices using avr controllers, they gave a good adress with fast service and low prices. So now I can play with the avr architecture without spending a lot of money.

compiler

There is a good C library available for use with gcc: avr-libc.
avr-gcc -mmcu=atmega32 -Os -L/usr/i586-pc-linux-gnu/avr/lib/ -o avrblink.elf avrblink.c

blink a led

The hello world of embedded systems, to see if the toolchain works.
Here is the schematic

The

programmer 1

An atmel avr can be programmed via the parallel port of the computer wihout any extra components. That is how my first programmer works. Only 2 resistors for safety.
Avrdude designed the bsd programmer. The pinout is as follows:
programmer function paralel portatmega8
resetpin 7pin 1
sckpin 8pin 19
mosipin 9pin 17
misopin 10pin 18
GNDpin 18pin 8

To test the connections the following command can be used:
avrdude -c bsd -P lpt1 -p m8 -U lfuse:r:con:a

programmer 2

As the lpt port is missing more and more on newer computers, an USB programmer is a far better option.


below are the 2 programmers


These are the USBAsp prints


usb to rs232

the atmega has a build in usart for rs232 transfers. but just as a parallel port, the rs232 port is often missing and inconvenient. There are good usb->rs232 adaptors available, but they are expensive and require big connectors level shifters etc. So therefore a special chip is needed. why not an avr?
the avr-cdc is just right.
Below is the schematic which I used.


the sources are here

the build command was:
avrdude -v -p m88 -c usbasp -U flash:w:cdcmega88p.hex -U hfuse:w:0xdf:m -U lfuse:w:0xfe:m

the result is:


on connection dmesg showed the following lines:
 Device driver usbdev3.3_ep00 lacks bus and class support for being resumed.
 usb 3-3: configuration #1 chosen from 1 choice
 cdc_acm 3-3:1.0: ttyACM0: USB ACM device
 usbcore: registered new interface driver cdc_acm
 drivers/usb/class/cdc-acm.c: v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters

testing rs232 communication


project 1, IR receiver

an atmega8 with a tsop1735 receiver will decode a rc5 signal.