การสร้างโปรเจคใหม่
Project-> New project
Step 1 สร้าง Directory เพื่อเก็บ Project
Step 2 เลือกไมโคร ATmega168
Step 3 คลิกเลือก GNU C สังเกตด้วยว่า GCC path อยู่ตรงตำแหน่งที่เก็บ WinAVR-20100110 หรือไม่ ถ้าไม่ให้แก้ไข
Step 4 เลือก Add this เพิ่มไฟล์ภาษา C ใว้ใน Project
คลิก OK
ตัวอย่างไฟลโปรเจค
; ************************************************************
; PROJECT:
; AUTHOR:
; ************************************************************
; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega168"
.TOOLCHAIN "GCC"
.GCCPATH "C:\WinAVR-20100110"
.GCCMAKE AUTO
.TARGET "example.hex"
.SOURCE "example.c"
.TRACE ; Activate micro trace
; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0 ; Power nodes
.CLOCK 1meg ; Micro clock
.STORE 250m ; Trace (micro+signals) storage time
; Micro nodes: RESET, AREF, PB0-PB7, PC0-PC6, PD0-PD7, ACO, TIM1OVF, ADC6, ADC7
; Define here the hardware around the micro
; ------------------------------------------------------------
เปิดไฟล์โปรแกรม แล้วแก้ไขให้เหลือเพียง
#include <avr\io.h> // Most basic include files
#include <avr\interrupt.h> // Add the necessary ones
#include <avr\signal.h> // here
// Define here the global static variables
int a;
// ***********************************************************
// Main program
//
int main(void) {
a = 01;
while(1) { // Infinite loop; define here the
a>>= 1;
}
}
แปลโปรแกรม
Project -> Build
กำหนดค่าตัวแปรที่ต้องการดู
Debug -> Watch manager แล้วคลิกเลือกตัวแปร แล้วปิดหน้าต่าง
แสดงค่าตัวแปร
View -> Watch
การ Run โปรแกรม
Run Prgram ที่ละสเต็ป
Run -> Step into หรือ F7
RUN แบบต่อเนื่อง
RUN -> Go/Continune หรือ F5
หรือเลือกคลิกที่ไอคอนต่อไปนี้