AVR di LinuX – How To…

hehe 🙂

just smile before you read…

banyak compiler untuk microcontroller yang biasanya di pake oleh para hobi dan mahasiswa di indonesia, pada umumnya di lingkungan windows, compiler yang dipakai adalah Codevision dan Bascom. ya tergantung tu mahasiswa maunya pake bahasa apa. Codevision untuk , Bascom untuk Basic, AVR studio untuk Assembly, AVRco untuk Pascal, dan banyak deh..

nah…hampir semua IDE(integrated development environtment) di atas itu ga gratis cuy, yang gratis palingan cuma AVR studio aja, bawaan Atmel.

ok… now… GOIN’ TO OPEN SOURCE…

opensource avr di lingkungan windows = WinAVR…, winAvr ini adalah IDE gratis buat ngompile dan ngedit2 program AVR pake bahasa C…itu cukup?! TIDAK!!

karena nanggung cuy, klo lo migrasi sistem stengah2…blm tentu juga wuh windows lo tuh asli..nah lo…

AVR-GCC & Linux

ini adalah solusinya…

pilih salah satu distro linux ksukaan lo..(penulis make ubuntu 8.1)

ok.. the steps

1. make sure klo lo pake linux..

2. download paket yang di butuhkan

$ sudo apt-get install gcc-avr

$ sudo apt-get install avr-libc

$ sudo apt-get install avrdude

3. tulis program contoh…misal testled.c

#define F_CPU 12000000UL  //setting crystal yang lo pake
#include <avr/io.h> //standart file IO header
#include <avr/iom16.h> // lib buat atmega16, lo pake apa..misal atmega8, iom8
#include <avr/delay.h>

void delayms(uint16_t millis) {
uint16_t loop;
while ( millis ) {
_delay_ms(1);
millis–;
}
}

int main(void) {
DDRC = 0xFF; /* set jadi Output..*/
while(1) {
PORTC = 0x00; /* LED on */
delayms(1000);
PORTC = 0xFF; /* LED off */
delayms(1000);
}
return 0;
}

4. Buat Makefilenya…

#
# Makefile for Tom’s AVR-Board with STK200 Parallel Programmer
# by Tommy Agustianto <satria.nt@gmail.com>
# ver 0.1
#

CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega16
OBJ2HEX=avr-objcopy
AVRDUDE=avrdude
TARGET=testled

program : $(TARGET).hex
$(AVRDUDE)  -p m16 -P /dev/parport0 -c stk200 -U flash:w:testled.hex
if=$(TARGET).hex -v=2
%.obj : %.o
$(CC) $(CFLAGS) $< -o $@

%.hex : %.obj
$(OBJ2HEX) -R .eeprom -O ihex $< $@

clean :
rm -f *.hex *.obj *.o *~

okeh…smua udah terinstal dan lo juga udah buat file yang di perlukan , jangan lupa tapo tuh testled.c dan Makefile di folder yang sama…

dan ….coba dah lo ketik

make

klo smuanya benar, nanti akan ada tulisan bgini..

tommy@xsatria:~/myprojects/AVR-Linux$ sudo make
[sudo] password for tommy:
avrdude   -p m16 -P /dev/parport0 -c stk200 -U flash:w:testled.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9403
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file “testled.hex”
avrdude: input file testled.hex auto detected as Intel Hex
avrdude: writing flash (214 bytes):

Writing | ################################################## | 100% 0.18s

avrdude: 214 bytes of flash written
avrdude: verifying flash memory against testled.hex:
avrdude: load data flash data from input file testled.hex:
avrdude: input file testled.hex auto detected as Intel Hex
avrdude: input file testled.hex contains 214 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.20s

avrdude: verifying …
avrdude: 214 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

nah, skarang lepas kabel download lu…dan hehehehe…

IT WORKS…isn’t it?

nih skematik stk200 gw…cuma modal goceng bro…

ga usah pake buffer2an…cuma resistor 4buah n lpt male connector..

toms stk200
toms stk200


Tulisan ini dibuat untuk menyukseskan Lomba Blog Open Source P2I-LIPI dan
Seminar Open Source P2I-LIPI 2009.

http://www.informatika.lipi.go.id/seminar/lombablog/
http://www.informatika.lipi.go.id/seminar/


Advertisements
AVR di LinuX – How To…

2 thoughts on “AVR di LinuX – How To…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s