390 likes | 620 Views
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 …. microprocessor.
E N D
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 • …
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.
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.) , …
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
Harvard architecture vs. von Neumann architecture • von Neumann architecture • both cannot occur at the same time • Harvard architecture • CPU can both read an instruction and perform a data memory access at the same time
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
Pinout of ATmega128 TQFP : thin quad flat pack c.f) MLF : Micro Lead Frame
Development Environment • AVR Studio : 프로그램, 다운로드 • Win AVR : 컴파일 • USB ISP : 다운로드(USB driver) 프로그램 컴파일 다운로드 실행
AVR Studio 내려받기 • http://www.atmel.com • Download AVR Studio 4.18 • Register required • Datasheet • ATmega128
WinAVR 내려받기 • http://sourceforge.net/projects/winavr/files/
개발환경 설치 • AVR Studio 설치 • 처음 단계에서 아래와 같은 초기 화면이 표시 • [다음] 선택하고 License Agreement 화면에서 Accept
개발환경 설치 • 소프트웨어 설치 경로 지정 • AVR Studio 에서 이용하게 되는 USB 포트 드라이브 설치
개발환경 설치 • 설치에 대한 모든 설정항목이 완료되었고 설치를 진행함을 알리는 화면
개발환경 설치 • 모든 설치가 완료되었음을 알리는 화면
개발환경 설치 • WinAVR 설치하기 • 초기 화면에서 설치 시 표시될 언어를 선택하는 화면 • [KOREA] 선택 후 환인 버튼
개발환경 설치 • WinAVR 에 대한 라이센스에 동의를 구하는 화면 • 기본 설치 경로 사용
개발환경 설치 • 기본으로 설정된 구성요소 선택 후 [설치] 선택 • 프로그래밍 설치되는 과정 수분의 시간이 소요
개발환경 설치 • 설치가 완료되었음을 알리는 화면 • [시작]-[프로그램]–[Atmel AVR Tools] 폴더 확인
개발환경 설치 • Usb ISP 프로그래머 설치 • 프로그램을 컴파일 시 AVR 마이크로컨트롤러에서 동작을 시킬 수 있는 실행 파일이 만들어짐 • 실행 파일을 AVR 마이크로컨트롤러의 프로그램 메모리, 즉 플래쉬 메모리로 옮겨 적재시키는 작업(다운로딩)을 위한 드라이버 설치 • 장비에 USB Connector A to B Type을 이용하여 컴퓨터의 USB Port 에 연결 • AVR ISP Programmer 장치를 Connector와 연결 • 드라이버는 다음과 같은 사이트를 방문 후 절차대로 설치함
개발환경 설치 • VCP 설치 • http://www.ftdichip.com/Drivers/VCP.htm • 해당 사이트로부터 CDM 2.00.00.zip 파일을 다운로드
개발환경 설치 • HBE-MCU-Multi의 AVR ISP Programmer를 PC의 USB포트에 연결 • 연결 후 새 하드웨어 검색 마법사에서 설치 • “목록 또는 특정 위치에서 설치(고급)”을 선택 후 [다음] 클릭 후 [찾아보기] 클릭하여 CDM 2.00.00을 찾아 선택
개발환경 설치 • [마침] 클릭하여 드라이버 설치 종료
HBE-RoboMotor-SE 실습 준비 • 마이크로프로세서 파트(MCU Part) 의 상태를 체크. • MCU /Module 스위치 상태를 MCU상태로 유지 • Auto/User 스위치 상태를 User 상태로 유지 • AD Port/JTAG 스위치 상태를 JTAG상태로 유지 • MCU Part 의 ISP와 AVR-ISP Programmer와 연결 • AVR-ISP Programmer와 PC 연결 • AVR-ISP Programmer의 mode는 ISP
개발환경 사용 • AVR Studio 처음 실행 • Atmel사의 AVR Studio를 처음 사용하는 사용자를 위해 간단한 예제를 이용 • 작성한 코드를 컴파일하고 이를 장비에 프로그램하는 과정을 진행 • [시작]-[프로그램]-[Atmel AVR Tools]-[AVR Studio4] 선택
개발환경 사용 • 프로그램 초기 화면에서는 AVR Project를 생성하거나 이미 만들어진 프로젝트를 오픈하는 화면이 표시됨 • [New Project] 선택
개발환경 사용 • Project 생성에 필요한 항목 지정하는 화면 • Project name과 Create folder, Initial file, 프로젝트를 저장할 폴더의 Location 등 설정 • Debug platform : JTAG ICE 설정 • Device : ATmega128 설정
개발환경 사용 • 기본 프로젝트 생성 완료 후 AVR Studio 메인화면이 표시됨 • 화면에는 공란의 Getting_Start.c 파일이 표시 • 다음과 같은 코드를 입력 #include<avr/io.h> 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; }
개발환경 사용 #include<avr/io.h> 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; }
개발환경 사용 • 코드 입력 후 [Build]-[Build] 선택하여 코드를 컴파일 및 프로그램 파일을 생성하는 과정 수행 • 정상적으로 Build 수행 후 프로그램 코드를 다운로드 진행 • 화면 상단 중앙에 [Con] 아이콘을 선택
개발환경 사용 • AVR 디바이스를 프로그램하기 위한 프로그래머 선택 • Plaform : STK500 or AVRISP 선택 • Port : 프로그래머가 연결된 포트 선택(장치관리자 참조) • [Connect] 선택
개발환경 사용 • Device : ATmega128 선택 • Programming mode : ISP mode 선택 • Build 과정에서 프로그램 다운로드에 필요한 HEX 파일이 프로젝터 폴더에 있는 ‘default’라는 폴더에 만들어짐 • HEX 파일을 Flash 항목에 입력 • [Program] 선택 하면 프로그램 다운로드가 진행 • 프로그램 다운로드가 완료되면 아래의 메시지 창에 다운로드가 정상적으로 완료되었음을 알림
개발환경 사용 • AVR Device 설정을 위한 Fuse 과정을 수행 • AVR Device의 동작을 설정하는 항목 • 설정 후 [Program] 선택