Programming MCU
Programming Atmel ATmega8l microcontroller
Intro
For the next article I've decided to go further into the hardware. For my next project I've chosen to program a micro controller (MCU). I've got no experience with MCUs before and this article will show my whole process.First steps
My colleague advised me a usb-avr programmer which is compatible with AVR Atmel micro controllers.So I ordered this usb-avr programmer, ATmega8L microcontroller, some resistors, leds and a breadboard.
I prefer using IDEs (syntax highlights, build from one place, save time and trees) so I chose Eclipse. There is a nice tutorial how to setup an Eclipse plugin for avr programming, but mainly you just need to install these libraries.
- gcc-avr -> library for use with GCC on Atmel AVR micro controllers
- binutils-avr -> cross compiling version of GNU binutils
- gdb-avr -> GDB for (remote) debugging avr binaries
- avr-libc -> C library for use with GCC on Atmel AVR micro controllers
- avrdude -> transfers hex file onto microcontroller
work with MCU
This MCU ATmega8l is a 8-bit RISC Architecture Microcontroller with 8Kbytes of Flash program memory. It has many cool features (timer, ADC, 3 PWM channels etc. ). Here is a full documentation.Anyway, it has 28 pins from which 23 can be used as GPIO. These 23 pins are divided into 3 ports. Each port has 8 bits (one of ports allows only 7 bits). Setting up these ports allows us to use pins as input or output. Here is a very helpful page about avr programming.
At the end, the program is compiled into hexadecimal format, and then written onto the flash memory of a micro controller.
Testing, first project
I used 20 red LEDs (5mm) and make a field 5 x 4 of them. Each led was joined to separate pin of micro controller. After making a mapping method for each led I created some basic effects and snake with backtrack search. You can download the source code below.download source code here
Comments
Post a Comment