Transcript L01_intro

Introduction to AVR & Development Environment Setting

Microcomputer

a computer with a microprocessor as its central processing unit personal computer or computer c.f.) mainframe, minicomputer as a subject Computer architecture Assembler Memory Interface I/O Interface …

incoming Lab.

microprocessor

A microprocessor incorporates most or all of the functions of a computer's central processing unit (CPU) on a single integrated circuit (IC, or microchip).

General purpose  Pentium, AMD, MC68000, … Digital Signal Processor (DSP)  optimized specifically for digital signal processing Advanced RISC Machine(ARM) processor  mobile and embedded electronics Micro-controller(MCU)  designed for embedded applications … * CPU : carries out the instructions of a computer program.

incoming Lab.

Micro-Controller

a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals µC or MCU(micro-controller unit) 시스템 내부의 칩 개수를 줄여줌으로써 , 가볍고 작은 시스템 을 만들 수 있게 해준다 가격을 최적화할 수 있으며 , 제품의 개발기간을 줄여줄 수 있다 8051(Intel), AVR(Atmel), PIC(Microchip Tech.) , …

incoming Lab.

AVR micro-controller

a modified Harvard architecture 8-bit RISC single chip micro-controller (Atmel) architecture was conceived by two students at the Norwegian Institute of Technology (NTH) Alf-Egil Bogen and Vegard Wollan first microcontroller families to use on-chip flash memory for program storage megaAVR — the ATmega series 4–256 kB program memory 28–100-pin package Extended instruction set Extensive peripheral set ATmega128 : 128K program memory

incoming Lab.

Harvard architecture vs. von Neumann architecture

Harvard architecture CPU can both read an instruction and perform a data memory access at the same time von Neumann architecture both cannot occur at the same time

incoming Lab.

RISC vs. CISC

RISC Reduced Instruction Set Computing a CPU design strategy based on the insight that simplified (as opposed to complex) instructions can provide higher performance if this simplicity enables much faster execution of each instruction CISC Complex Instruction Set Computing each instruction can execute several low-level operations, such as a load from memory, an arithmetic operation, and a memory store, all in a single instruction

incoming Lab.

Pinout of ATmega128

TQFP : thin quad flat pack c.f) MLF : Micro Lead Frame

incoming Lab.

Internal Architecture of ATmega128

incoming Lab.

Development Environment

프로그램 컴파일 다운로드 AVR Studio : 프로그램 , 다운로드 Win AVR : 컴파일 USB ISP : 다운로드 (USB driver) 실행

incoming Lab.

AVR Studio

내려받기

http://www.atmel.com

Download AVR Studio 4.18

Register required Datasheet ATmega128

incoming Lab.

WinAVR

내려받기

http://sourceforge.net/projects/winavr/files/

incoming Lab.

개발환경 설치

AVR Studio 설치 처음 단계에서 아래와 같은 초기 화면이 표시 [ 다음 ] 선택하고 License Agreement 화면에서 Accept

incoming Lab.

개발환경 설치

소프트웨어 설치 경로 지정 AVR Studio 에서 이용하게 되는 USB 포트 드라이브 설치

incoming Lab.

개발환경 설치

설치에 대한 모든 설정항목이 완료되었고 설치를 진행함을 알리는 화면

incoming Lab.

개발환경 설치

모든 설치가 완료되었음을 알리는 화면

incoming Lab.

개발환경 설치

WinAVR 설치하기 초기 화면에서 설치 시 표시될 언어를 선택하는 화면 [KOREA] 선택 후 환인 버튼

incoming Lab.

개발환경 설치

WinAVR 에 대한 라이센스에 동의를 구하는 화면 기본 설치 경로 사용

incoming Lab.

개발환경 설치

기본으로 설정된 구성요소 선택 후 [ 설치 ] 선택 프로그래밍 설치되는 과정 수분의 시간이 소요

incoming Lab.

개발환경 설치

설치가 완료되었음을 알리는 화면 [ 시작 ]-[ 프로그램 ] – [Atmel AVR Tools] 폴더 확인

incoming Lab.

개발환경 설치

Usb ISP 프로그래머 설치 프로그램을 컴파일 시 AVR 마이크로컨트롤러에서 동작을 시킬 수 있는 실행 파일이 만들어짐 실행 파일을 AVR 마이크로컨트롤러의 프로그램 메모리 , 즉 플래 쉬 메모리로 옮겨 적재시키는 작업 ( 다운로딩 ) 을 위한 드라이버 설 치   장비에 USB Connector A to B Type 을 이용하여 컴퓨터의 USB Port 에 연결 AVR ISP Programmer 장치를 Connector 와 연결  드라이버는 다음과 같은 사이트를 방문 후 절차대로 설치함

incoming Lab.

개발환경 설치

VCP 설치 http://www.ftdichip.com/Drivers/VCP.htm

해당 사이트로부터 CDM 2.00.00.zip 파일을 다운로드

incoming Lab.

개발환경 설치

HBE-MCU-Multi 의 결 AVR ISP Programmer 를 PC 의 USB 포트에 연 연결 후 새 하드웨어 검색 마법사에서 설치 “목록 또는 특정 위치에서 설치 ( 고급 ) ” 을 선택 후 [ 찾아보기 ] 클릭하여 CDM 2.00.00

을 찾아 선택 [ 다음 ] 클릭 후

incoming Lab.

개발환경 설치

[ 마침 ] 클릭하여 드라이버 설치 종료

incoming Lab.

HBE-RoboMotor-SE

실습환경

incoming Lab.

HBE-RoboMotor-SE

실습 준비

마이크로프로세서 파트 (MCU Part) 의 상태를 체크 .

① ② ③ MCU /Module 스위치 상태를

MCU

상태로 유지 Auto/User 스위치 상태를

User

AD Port/JTAG 스위치 상태를 상태로 유지

JTAG

상태로 유지 MCU Part 의 ISP 와 AVR-ISP Programmer 와 연결 AVR-ISP Programmer 와 AVR-ISP Programmer 의 PC 연결 mode 는 ISP

incoming Lab.

개발환경 사용

AVR Studio 처음 실행 Atmel 사의 예제를 이용 AVR Studio 를 처음 사용하는 사용자를 위해 간단한 작성한 코드를 컴파일하고 이를 장비에 프로그램하는 과정을 진행 [ 시작 ]-[ 프로그램 ]-[Atmel AVR Tools]-[AVR Studio4] 선택 27

incoming Lab.

개발환경 사용

프로그램 초기 화면에서는 AVR Project 를 생성하거나 이미 만들 어진 프로젝트를 오픈하는 화면이 표시됨 [New Project] 선택 28

incoming Lab.

개발환경 사용

Project 생성에 필요한 항목 지정하는 화면 Project name 과 의 Create folder, Initial file, 프로젝트를 저장할 폴더 Location 등 설정 Debug platform : JTAG ICE 설정 Device : ATmega128 설정 29

incoming Lab.

개발환경 사용

기본 프로젝트 생성 완료 후 AVR Studio 메인화면이 표시됨 화면에는 공란의 Getting_Start.c 파일이 표시 다음과 같은 코드를 입력 #include int main(){ DDRB = 0xFF; DDRD = 0x00; while(1){ if(PIND & 0x40) PORTB |= 0x20; else PORTB &= ~0x20; } if(PIND & 0x80) PORTB |= 0x40; else PORTB &= ~0x40; } return 0; 30

incoming Lab.

개발환경 사용

#include int main(){ DDRB = 0xFF; DDRD = 0x00; while(1){ if(PIND & 0x40) PORTB |= 0x20; else PORTB &= ~0x20; } if(PIND & 0x80) PORTB |= 0x40; else PORTB &= ~0x40; } return 0; 31

incoming Lab.

개발환경 사용

코드 입력 후 [Build]-[Build] 선택하여 코드를 컴파일 및 프로그램 파일을 생성하는 과정 수행 정상적으로 Build 수행 후 프로그램 코드를 다운로드 진행 화면 상단 중앙에 [Con] 아이콘을 선택 32

incoming Lab.

개발환경 사용

AVR 디바이스를 프로그램하기 위한 프로그래머 선택 Plaform : STK500 or AVRISP 선택 Port : 프로그래머가 연결된 포트 선택 ( 장치관리자 참조 ) [Connect] 선택 33

incoming Lab.

개발환경 사용

Device : ATmega128 선택 Programming mode : ISP mode 선택 Build 과정에서 프로그램 다운로드에 필요한 터 폴더에 있는 ‘ default ’ 라는 폴더에 만들어짐 HEX 파일이 프로젝 HEX 파일을 Flash 항목에 입력 [Program] 선택 하면 프로그램 다운로드가 진행 프로그램 다운로드가 완료되면 아래의 메시지 창에 다운로드가 정 상적으로 완료되었음을 알림 34

incoming Lab.

개발환경 사용

35

incoming Lab.

개발환경 사용

AVR Device 설정을 위한 Fuse 과정을 수행 AVR Device 의 동작을 설정하는 항목 설정 후 [Program] 선택 36

incoming Lab.