마이크로칩 2005 년부산세미나 Class 6 : PICkit2 Hands-On Training Slide 1
Agenda 마이크로칩회사소개마이크로컨트롤러와 PIC MCU 개요 PICmicro MCU 명령어구조데이터시트 & 라인카드개요마이크로칩개발환경 MPLAB IDE & PICKIT2 사용법 Hand-On Labs Slide 2
Agenda for Hands-on Labs Lab 1 : Hello World 개발환경구축및 LED 켜기 Lab 2 : Blink Time Delay 를이용한 LED 깜빡이기 Lab 3 : Rotate LED 회전 Lab 4 : A2D AD 변환후 AD 값 LED Display Lab 5 : Debounce SW 입력에따른 LED 제어 Lab 6 : Timer0 Timer0 를이용한 Delay Lab 7 : Interrupt Timer0 Interrupt 를이용한 Delay Slide 3
마이크로칩회사소개 Slide 4
회사소개 1989 년설립 전세계 24 개영업사무소 ISO 9001 과 QS-9000 인증획득 반도체공정 (Fabrication) 설비 : 아리조나주템피, 오래곤주그레샴 조립생산및검사시설 : 태국방콕, 중국상해 : ANAM & AMKOR 에하청, 위탁생산 디자인설비 : 캘리포니아주마운틴뷰와인도뱅갈로 본사 : 미국아리조나주피닉스 ( 챈들러 ) 공급제품 : - 8bit RISC MCU ( 6/8/14/18(20)/28/40(44)/64(68)/80(84) pin ) - Analog 소자 - rfpic 소자 ( 송, 수신 parts ) - EEPROM -KEELOQ 보안용소자 - 16 bit dspic DSC(digital signal controller) - Smart power gauging solution Slide 5
PICmicro MCU 연혁 1989 첫 MCU 출시 : PIC16C5X family 1990 1백만개제품판매달성 1991 세계최초 Windows 3.0 기반개발장비출시 1992 대량생산체제가능한 Masking 라인구축 1994 FLASH PICmicro 마이콤출시 1996 세계최초 8 비트 8핀마이콤출시 시장점유율세계 5위달성 1997 8 wafer 생산시작 시장점유율세계 2위달성 1999 PIC18FXXX 마이콤발표 MCU 일백만개판매달성 2000 FLASH PICmicro 제품군확장 2001 세계적으로인증된 Telcom 인수및 Analog 제품군확장 2002 Powersmart 인수및 Total solution 제공 (Duracell 반도체설계회사 ) 2003 8-bit MCU 시장점유율세계 1위달성 ( 수량 base) 2004 16-bit MCU 및 dspic 시장진입, 8bit 6pin MCU 출시 * 현재 1일 MCU 170만개씩출하중. Slide 6
전세계공장위치 Oregon Fab 4 Shanghai Test & Assembly Arizona Corp. HQ Fab 2 Bangkok Test & Assembly Slide 7
전세계기술지원센터 Toronto Detroit Boston Mountain View Chicago New York San Jose Dayton Los Angeles Atlanta Phoenix Dallas Denmark London Paris Munich Switzerland Milan India Seoul Bejing Tokyo Shanghai Shenzen Taipei Hong Kong Singapore 206 Application Engineers serving North America 152 Application Engineers serving Europe 194 Application Engineers serving Far East Sydney Slide 8
전세계디자인센터위치 Silicon Valley Plano, TX New York* Lausanne, Switzerland Shanghai, China Chandler, AZ Bangalore, India Slide 9
Balanced Global Revenue Americas 29% Europe 28% Asia/Japan 43% Slide 10
Microchip Sales by Market Segment Telecom 13% Industrial 17% Office Automation 17% Automotive 18% Consumer 35% Slide 11
Development Systems Shipped 300000 305,000 261,994 250000 227,000 203,000 200000 170,000 150000 119,000 141,000 100000 63,000 90,000 50000 23,000 41,000 9,000 0 FY 93 FY 94 FY 95 FY 96 FY 97 FY 98 FY 99 FY 00 FY 01 FY 02 FY 03 FY 04 Slide 12
World Class Manufacturing - 마이콤웨이퍼가공수율 ( 평균 95% 이상 ) PICmicro Die Yield Percent 100 90 80 70 60 50 40 30 20 10 1990 1993 1995 2000 2004 Slide 13
0.7 µm Flash/EPROM/ROM 120K 0.5 µm Flash/ROM 150K Process Technology Roadmap 0.4 µm Flash 160K 0.35 µm Flash 185K 0.22 µm Flash 200K 2-5.5 V Operation 2-3.6 V core Operation 5V I/O 2-3.6 V core Operation 5V I/O 1998 2001 2003 ===== 2006===== Production Slide 14 Year
Process Technology Advancements PIC18C452 (0.7µ) PIC18F452 (0.5µ) PIC18F4520 (0.4µ) Slide 15
전세계 8-Bit MCU 시장 -Units 1991 1992 1993 1994 1995/96 1997-01 2004 No. Rank Rank Rank Rank Rank Rank Rank 1 Motorola Motorola Motorola Motorola Motorola Motorola Microchip 2 Mitsubishi Mitsubishi Mitsubishi Mitsubishi Mitsubishi Microchip Motorola 3 NEC Intel NEC NEC SGS-Thomson ST-Micro ST-Micro 4 Intel NEC Hitachi Philips NEC NEC NEC 5 Hitachi Philips Philips Intel Microchip Philips Atmel 6 Philips Hitachi Intel Microchip Philips Atmel Sunplus 7 Matsushita Matsushita SGS-Thomson Zilog Zilog Hitachi Hitachi 8 SGS-Thomson SGS-Thomson Microchip SGS-Thomson Hitachi Toshiba Fijitsu 9 Siemens National Matsushita Matsushita Fujitsu Samsung Philips 10 TI TI Toshiba Hitachi Intel Elan Toshiba 11 National Zilog National Toshiba Siemens Zilog Mitsubishi 12 Toshiba Toshiba Zilog National Toshiba Matsushita Samsung 13 Sony Siemens TI TI Matsushita Infineon Elan 14 Sharp Microchip Siemens Ricoh TI Fujitsu Winbond 15 Oki Sharp Sharp Fujitsu National Mitsubishi Zilog 16 Zilog Sanyo Oki Siemens Temic Sanyo Sanyo 17 Microchip Matra MHS Sony Sharp Sanyo Winbond Matsushita 18 Matra MHS Sony Sanyo Oki Ricoh National Infineon 19 Fujitsu Oki Fujitsu Sony Oki Sony Holtek 20 Sanyo Fujitsu AMD Temic Sharp Holtek National Slide 16
제품응용분야 Consumer TV/VCR equipment Stereo receiver CD player 리모콘 Cable TV converter 게임 Video games 카메라창고 Carbon Monoxide detector 전자레인지식기세척기 / 건조기 Kitchen appliances Cordless tools 공기청정기 Electric blanket Automotive 자동경보장치 Keyless entry Radar detector Cruise control ABS 시스템속도측정기 Climate control Turn signals Active suspension 연료펌프제어 Fuel injection Sun roof control Air bag sensor Power seats Office Automation 마우스노우트북트랙볼키보드휴대용스캐너 Laser printer interface board PC LAN system X/Y plotter 복사기 Bar code reader Disk drive Tape back-up unit Serial bus 팩스 Telecom 휴대폰무선전화기기능성전화기자동응답기 Pay phone Modem 발신자확인기 Industrial Motor 제어 Compressor Thermostat Postage meter Utility meter Robotics Process control Gas pump Smoke detector Credit card reader Access Control Slide 17
Consumer Black & Decker Goldstar Hamilton Beach JVC 미츠비시파낙소닉필립스삼성산요세가 Coleman 소니도시바 Voice It Whirlpool Automotive Blaupunkt BMW 포드 GM-Delco 혼다렉서스벤츠닛산보쉬지멘스토요다 TRW Valeo 삼성르노현대기아대우 GM Office Automation 알프스 애플 Conner 컴팩 DEC IBM 로지테크 Microsoft 미츠비시 NCR 파낙소닉퀀텀 Synaptics 주요고객 텍사스인스트루먼트 HP Telecom Codex 에릭슨 Hayes 교세라모토로라노키아 Northern Telecom Pacific Monolithics Rockwell 지멘스 UDS Industrial Allen-Bradley American Sensors Code Alarm Foxboro 제네럴일렉트릭 Honeywell Pitney Bowes Robertshaw Tandy United Technologies Wayne Systems ILCO-Unican Slide 18
Microchip 제품군 Digital Pot Precision Voltage Reference RF Xmit/receive High Voltage IR I/O s Communication Telecom DTMF Codec Sensors Amplifiers Filters A/D Power Drivers Motors Relays Print-heads Serial NV Memory Power Power Management - Regulators - Supervisory Microcontrollers D/A LCD Drivers VF Drivers SRAM Transceivers - RS232/485 - CAN bus - USB Bus Comm - CAN bus -USB -I 2 C - SPI - RS422/423 Digital Peripherals PWM RTC Encryption (KEELOQ ) Speech Co-Processing LED Drivers Slide 19
Microchip s PIC18FXXXX Extended Family PIC17CXXX High-End Family PIC16F6XX6XX Mid-Range Family PIC16F5X Baseline Family PIC12FXXX 8-Pin Family PIC10F2XX 6pin Family 16-Bit Micom 제품구성 32-Bit PIC24FXXX 16bit Family dspic30fxxxx 16bit Family PIC24FXXX 16bit Family 8-Bit 4-Bit Slide 20
PICmicro 의장점 8-Bit MCU 선두업체 - OTP/FLASH/QTP 빠른속도 - 5 to 10 MIPS Performance 저전력 100nA typical @ 2V Standby current, 다양한절전모드 Flash MCU 의풍부한제품군보유 다양한 Digital Peripherals UART, USB, CAN, LIN, SPI, I2C 다양한 Analog Peripherals ADC, Comparator 저렴한가격대의 3rd Party 개발장비 Digilink,Comfile 강력한개발장비 MPLAB-ICE2000 ( 2.0V / 40MHZ 동작 ) ICE4000, Promate III 및 ICD1, ICD2 FAE 를통한포괄적인개발지원 고객감동영업 Slide 21
PICmicro MCU Product Migration Path 285 이상의다양한제품군 6-Pin Family.25KWord.5KWord FLASH, OTP and ROM 뛰어난아날로그기능뛰어난내구성의 FLASH Migration 이쉬운다양한제품군 8-Pin Family.5KWord 2KWord 14-Pin Family 1KWord 4KWord 18/20-Pin Family.5KWord 4KWord 28-Pin Family.5KWord 32KWord 40/44-Pin Family 2KWord 32KWord Seamless Migration 64/68-Pin Family 4KWord 64KWord 80/84-Pin Family 4KWord 64KWord Slide 22
제품의신뢰성 ISO9001 Certification QS9000 Certification(Automotive) Quality Awards from numerous Fortune 100 customers PPM levels consistently below 10 Field Failures for PICmicro MCUs virtually non-existent Slide 23
Pb-Free Packages ( 환경친화 Solution) Matte tin = 순수 Sn, 어떤혼합물이나 bismuth [Bi] 도없음. 보통 Pb-free 제품의솔더링온도는 260ºC. Microchip 의 G -rated (Pb-free) 제품의솔더링온도는 220ºC 에서 260ºC 로기존제품과 Pb-free 제품의솔더온도를모두만족. 새로운솔더링에대한어플리케이션노트 : AN233 참조 2005 년부터모든제품에적용. Slide 24
마이크로컨트롤러와 PIC MCU 개요 Slide 25
마이크로콘트롤러란무엇인가? ROM / PROM / EPROM / EEPROM / FLASH DRAM/SRAM PROGRAM COUNTER STACK REGISTER SINK/SOURCE BANK/PAGE UART / I2C / SPI / 3-WIRE interface VSS / VDD / OST / RESET PACKAGE Watch Dog Timer ( WDT ) RESET (VECTOR) SLEEP CODE PROTECT STATUS REGISTER INTERRUPT Slide 26
하버드아키텍쳐 모든명령이 single word PICmicro 아키텍쳐 고성능의 PICmicro 디바이스는다음과같은중요한특징을지니고있다. 명령들이파이프라인구조를가짐 ( excute and fetch ) RISC(Reduced Instruction set code) 구조를가지며모든명령이한 cycle 에이루어진다. ( 단 Address branch 명령은제외 - GOTO,CALL ) Slide 27
PICmicro Architecture 하버드아키텍쳐란? 전통적인폰노이만아키텍쳐는하나의메모리로부터명령과데이터를페치함 CPU 8-Bits Program and Data Memory 하버드아키텍쳐는각각분리되어있는메모리를사용함으로써효율을극대화함 CPU 12/14/16-Bits Program Memory 8-Bits Data Memory Slide 28
PICmicro Architecture 하버드아키텍쳐는 single-word/single-cycle 명령어를가지고있다 PICmicro Movlw #imm<8> 폰노이만아키텍쳐는 2 Byte / 2 cycle 의구조를지닌다. 1100XX k k k k k k k k 따라서 size 측면에서는근사적으로하버드아키텍쳐는폰노이만아키텍쳐보다 2배정도의 performance 를가지고있다고할수있겠다. MC68HC05 ldaa #imm<8> 1000 0110 k k k k k k k k Slide 29
MOVF PORTB,W 001000 0 00110 PICMicro Architecture Block Diagram Clock/Counter EPROM Program Memory Program Bus Instruction Reg 001000 0 00110 Program Counter STACK1 STACKn Direct Addr Data Bus RAM Addr Addr Mux 00110 RAM File Registers Indirect Data Address FSR I/O Ports T0CKI 01010101 STATUS Reg Ports MCLR OSC1 OSC2 20 001000 0 Instruction Decode & Control Timing Generation Brown-out Reset Watchdog Timer Power-on Reset OSC Start -uptimer ALU Mux W Reg 01010101 Peripheral(s) Slide 30
PICmicro Architecture 레지스터파일의개념 ALU Data Memory INDF TMR0 PCL STATUS FSR PORTA Other SFRs W Register Slide 31 General Purpose Registers (RAM) 14-bit Instruction Format Example: Op code <7> Direct data addr <7>
PICmicro MCU Architecture 파이프라인구조 대부분의 MCU 는명령어들의 Fetch 와실행을순차적으로실행한다. PICmicro MCU 는 Fetch 와실행을동시에한다. One Instruction One Cycle 분기명령어는 (e.g. GOTO, CALL or WRITE to PC) 2 Cycle 로수행된다. Tcy0 Tcy1 Tcy2 Tcy3 Tcy4 1. MOVLW 55h Fetch 1 2. MOVWF PORTB 3. CALL SUB_1 4. BSF PORTA, BIT3 Execute 1 Fetch 2 Execute 2 Fetch 3 Execute 3 Fetch 4 Flush Fetch 4 Fetch SUB_1 Slide 32
PICmicro MCU Architecture Long Word Instruction (continued) PICmicro MCU movlw #imm<8> 1100XX k k k k k k k k MC68HC05 ldaa #imm<8> 1000 0110 k k k k k k k k Slide 33
PICmicro MCU Architecture Interrupt Overview PICmicro 에는다양한내부인터럽트와외부인터럽트가있다. 각각의인터럽트의우선순위는 Software 에서처리되어진다. 모든인터럽트를관리하는글로벌인터럽트인에이블비트 (GI) 와각각의인터럽트인에이블비트가존재한다다양한인터럽트는 SLEEP 모드로부터 Wakeup 시킬수있다인터럽트가걸려인터럽트써비스루틴까지의시간은 3 cycle 이걸린다 1. PC+1--> STACK 2. GI Bit clear 3. PC <---0X04 Slide 34
PICmicro Special Features POR/PWRT/OST Reset 기능이마이크로콘트롤러안에내장되어있으므로 Cost 절감효과를가진다밖에사용하는 crystal/resonator 의주파수가다르더라도 Oscillator Start-up Timer 를통하여안전하게주파수를맞추어사용가능하다. Power-up Timer 를통하여주변회로으로부터안전하게 reset 동작이가능하다 POR: Eliminates the need for external reset circuitry (internal chip-reset is generated on V DD rise detect: 1.2-2.0V range). OST: Oscillator start-up timer adjusts for different crystal / resonator frequency (holds device in reset for 1024 OSC cycles from POR). PWRT: Power-up timer protects against slow rising V DD (holds device in reset for 72ms from POR). Slide 35
PICmicro Special Features POR/PWRT/OST PIC16CXX-04 9714SAT V DD MCLR V DD MCLR PWRT OST T PWRT Reset T OST Execution Slide 36
PICmicro Special Features SLEEP Mode Battery 를사용하는 application 에서중요한 factor 는마이콤이얼마만큼의전류를소비하는가에달려있다 - idle / stop mode Sleep 명령을사용함으로써저전류소비모드로들어갈수있다 Main 오실레이터의동작이중단된다 Processor 의모든상태가유지된다 Watchdog Timer 는계속동작된다 보통 SLEEP 상태에서의전류소비는 0.1-2.0 µa typical Slide 37
PICmicro Special Features Wake-up From SLEEP MCLR WDT INT TMR1 ADC CMP CCP PORTB SSP PSP Events that wake processor from sleep Master Clear Pin Asserted (pulled low) Watchdog Timer Timeout INT Pin Interrupt Timer 1 Interrupt A/D Conversion Complete Interrupt Comparator Output Change Interrupt Input Capture Event PORTB Interrupt on Change Synchronous Serial Port (I 2 C Mode) Start/Stop Bit Detect Interrupt Parallel Slave Port Read or Write Slide 38
PICmicro Special Features Watchdog Timer (WDT) 란무엇인가? Software 의오동작으로부터의복원을도와준다 마이콤내부의 RC 오실레이터에의하여동작된다. WDT 는 Software 적으로디제이블할수없다 WDT time out 이발생되면마이콤은리셋된다. - Status register 의 TO bit CLRWDT 명령어로 WDT counter 를 clear 한다 일반적인 Time-out 주기는 18msec 이지만프로그램적으로약 3 초까지확장가능한다 WDT 를사용함으로써 SLEEP mode CLRWDT 로부터의탈피가가능하다 0 0 RC Oscillator 8-bit Ripple Counter Postscaler Overflow Resets Chip Slide 39
PICmicro Special Features Watchdog Timer (WDT) 란무엇인가? 중요한부분으로 WDT 는프로그램적으로안전하게 RESET 을시키기위한방법으로도사용되고있다 Start CodeByte = 0xA5? No CodeByte = 0xA5 WDTValue = 0 OPTION = 0b11111010 Yes WDTValue PORTB LOOP Wait 1ms increment WDTValue WDT Reset Slide 40
PICmicro Special Features Serial Programming ( ICSP 기능 ) MCLR/VPP VDD VSS RB6 RB7 PIC16CXX VPP VDD VSS Clock Data I/O Command 프로그램을위하여단지 2pin 만사용된다 RB6 : Clock input Pin RB7 : 데이터 I/O 나명령어 Input In-System Programming 측면에서보면 편리하다는점이다 For calibration For serialization PRO MATE II 에서지원가능하다. Slide 41
PICmicro Special Features Brown-Out Protection 마이크로콘트롤러는일정한 Voltage (3.7V-4.3V) 를 CHECK 하여이하로떨어졌을때마이콤의안정성을위하여 reset 시키는현상을 BOD 라한다리셋상태에서다시 Vdd 가일정한레벨로올라오면파워업타이머가동작한다 (72mS) 파워업타이머가동작중에다시일정 Voltage 이하로떨어지면 reset Mode 로들어간다이전까지는 BOD 기능이일정한 Voltage 로 Fix 되어있어서사용하기불편하였으나최근에나오는디바이스들은소프트웨어적으로자기가원하는 Voltage 를넣어줄수있도록되어있다. Slide 42
PICmicro Special Features Brown-Out Protection V DD BV DD BV DD BV DD Max BV DD Min Internal Reset 72 ms V DD BV DD BV DD BV DD Max BV DD Min Internal Reset < 72 ms 72 ms V DD BV DD BV DD BV DD Max BV DD Min Internal Reset 72 ms Slide 43
PICmicro Special Features Wakeup/Interrupt On Change 인터널 Pull-up pin 과 Wakeup/PORTB Interrupt Change가있다 ( 8pin 까지 ) Port Read I/O Pin Internal Pullup Data Bus Wake-up D Q Port Read Slide 44
PICmicro Special Features CLKOUTEN 4 Oscillators CLKOUT LP, XT, HS OSC Internal CLK CLKIN OSCCAL Register Setting Vdd INTRC EXTRC Oscillator Selection Fosc0 Fosc1 Fosc2 Slide 45
PICmicro Special Features Internal Oscillator Internal 4 MHz oscillator Software 적으로주파수를맞출수있다 ( Soft VDD adjustable ) OSCCAL Register Setting Internal Clock 4 CLKOUT Enable Slide 46
PICmicro Special Features 내부 RESET - Internal MCLR Reset핀조차도일반목적의 Input Pin으로사용할수있다. 그것은 device 를 writing 할때결정되어지는 Option 사항이다. 만약 MCLR Pin을일반 Input Pin으로사용하면 Reset function 은 device 내부적으로작용하게되어진다 VDD Read Port bit Data Bus GP3/MCLR/VPP MCLE Enable Internal MCLR Slide 47
PICmicro MCU 명령어 Slide 48
PICmicro MCU 명령어 33 instructions 12-bit core 35 instructions 14-bit core 58 instructions 16-bit core 배우기가쉽다 스피드가빠르다 모든명령어가 single-word Address branch 명령을제외하면모든명령어의실행은 single-cycle 로이루어진다. 호환성이강하다 Slide 49
PICmicro MCU Instruction Set 14-bit Core 명령어 REFERENCE Byte-Oriented Operation NOP - No Operation MOVWF f Move W to f CLRW - Clear W CLRF f Clear f SUBWF f,d Subtract W from f DECF f,d Decrement f IORWF f,d Inclusive OR W and f ANDWF f,d AND W and f XORWF f,d Exclusive OR W and f ADDWF f,d Add W and f MOVF f,d Move f COMF f,d Complement f INCF f,d Increment f DECFSZ f,d Decrement f, skip if zero RRF f,d Rotate right f RLF f,d Rotate left f SWAPF f,d Swap halves f INCFSZ f,d Increment f, skip if zero f = file register address d =destination select: 0 = W register, 1 = file register Bit-Oriented Operation BCF f,b Clear bit b of f BSF f,b Set bit b of f BTFSC f,b Test bit b of f and skip if 0 BTFSS f,b Test bit b of f and skip if 1 Literal and Control Operations SLEEP - Go into Standby Mode CLRWDT - Clear Watchdog Timer RETURN - Return from subroutine RETFIE - Return, enable interrupts RETLW k Return, place Literal in W CALL k Call Subroutine GOTO k Go to address (k is 9 bit) MOVLW k Move Literal to W IORLW k Inclusive OR Literal and W ANDLW k AND Literal W XORLW k Exclusive OR Literal W ADDLW k Add Literal W SUBLW k Subtract Literal from Slide 50
PICmicro MCU Instruction Set 바이트동작관련명령어 Byte-Oriented Operations NOP - No Operation MOVWF f Move W to f CLRW - Clear W CLRF f Clear f SUBWF f,d Subtract W from f DECF f,d Decrement f IORWF f,d Inclusive OR W and f ANDWF f,d AND W and f XORWF f,d Exclusive OR W and f ADDWF f,d Add W and f MOVF f,d Move f COMF f,d Complement f INCF f,d Increment f DECFSZ f,d Decrement f, skip if zero RRF f,d Rotate right f RLF f,d Rotate left f SWAPF f,d Swap halves f INCFSZ f,d Increment f, skip if zero Example for 14-bit core 13 8 7 6 0 OPCODE d = 0 for destination W d = 1 for destination f f = file register address d f f f f f f f Slide 51
PICmicro MCU Instruction Set 비트동작관련명령어 Bit-Oriented Operations BCF f,b Bit clear f, bit b BSF f,b Bit set f, bit b BTFSC f,b Bit test f, bit b skip if clear BTFSS f,b Bit test f, bit b skip if set Example for 14-bit core 13 10 9 7 6 0 OPCODE b b b f f f f f f f f = file register address b = bit address Slide 52
PICmicro MCU Instruction Set 상수및제어관련동작명령어 Literal and Control Operations SLEEP - Go into Standby Mode CLRWDT Clear Watchdog Timer RETLW k Return, place Literal in W CALL k Call Subroutine GOTO k Go to address (k is 9 bit) MOVLW k Move Literal to W IORLW k Inclusive OR Literal with W ANDLW k AND Literal with W XORLW k Exclusive OR Literal with W ADDLW k Add Literal to W SUBLW k Subtract W from Literal RETFIE - Return from interrupt RETURN - Return from subroutine New 14-bit instructions Example for 12-bit core 11 8 7 0 OPCODE k k k k k k k k k = literal value Slide 53
라인카드및데이터시트개요 Slide 54
Microchip Line Card Slide 55
Data Sheet Overview PIC12F629/675 PIC16F630/676 8-pin 14-pin 데이터시트를볼때중요한파라메터 Pinout/description Microcontroller/peripheral features Block diagram Absolute maximum ratings AC/DC characteristics Package information Ordering guide Slide 56
PICmicro MCU 8-Pin 8 Families VDD GP5/OSC1/CLKIN GP4/OSC2/AN3/CLKOUT GP3/MCLR/VPP 8-pin PICmicro Family VSS GP0/AN0 GP1/AN1/VREF GP2/TOCKI/AN2/INT PIC12C508A PIC12C509A PIC12CE518 PIC12CE519 PIC12C672 PIC12C671 PIC12CE673 PIC12CE674 PIC12F629 PIC12F675 Slide 57
8-pin to 14-pin Compatibility VDD GP5/T1CKI/OSC1/CLKIN 8 - Pin 14 - Pin VSS GP0/AN0/CIN+/ICSPDAT GP4/AN3/T1G/OSC2/CLKOUT GP1/AN1/CIN-/ICSPCLK VDDGP3/MCLR/VPP GP2/AN2/T0CKI/INT/COUT RC5 RC0/AN4 RC4 RC1/AN5 RC3/AN7 RC2/AN6 PIC12F629 to PIC16F630 Six extra I/O ports PIC12F675 to PIC16F676 Four extra A/Ds & Two extra I/O ports Slide 58
8-Pin & 14-Pin Features PIC12F629/PIC12F675 1.8K Bytes Flash Program (1Kw) 64 Bytes Data RAM 128 Bytes Data EEPROM 1 Comparator 1x8, 1x16 bit counters Precision Internal Osc Brown-Out Reset (BOR) Watchdog Timer (WDT) PDIP, SOIC, DFN 4 x 10-bit A/D (PIC12F675) PIC16F630/PIC16F676 1.8K Bytes Flash Program (1Kw) 64 Bytes Data RAM 128 Bytes Data EEPROM 1 Comparator 1x8, 1x16 bit counters Precision Internal Osc Brown-Out Reset (BOR) Watchdog Timer (WDT) PDIP, SOIC, TSSOP 8 x 10-bit A/D (PIC16F676) Slide 59
PIC12F629/675 Block Diagram in Data Sheet Slide 60
PIC12F629 & PIC16F676 Absolute Maximum Ratings Extreme specifications: Not recommended for normal operating conditions to meet system design parameters Slide 61
PIC12FXX & PIC16FXX DC Characteristics DC Characteristics Voltage and current levels used in normal operating conditions Slide 62
Typical frequency and timing requirements PIC12FXX and PIC16FXX AC Characteristics Slide 63
Package Information 8-Lead SOIC (150 mil) Most common PICmicro MCU 8-pin package Slide 64
마이크로칩개발환경 Slide 65
Built-in Editor PICmicro MCU 개발환경 MPLAB Integrated Development Environment Project Manager Source Level Debugger Language Products MPASM Assembler Low-cost Debugging MPLAB SIM Sofware Simulator Emulation and Analyis MPLAB ICE 2000 Device Programmers PICSTART Plus Third Party Tools C Compilers IAR Hi-Tech CCS MPLINK MPLIB MPLAB ICE 4000 PRO MATE II Real-time Operating Systems CMX, Vector, Realogy MPLAB C17 MPLAB C18 MPLAB C30 MPLAB ICD MPLAB ICD 2 PRO MATE 3 Libraried Routines Live Devices, CMX, Momentum Data Systems Slide 66
MPLAB ICE 4000 High Speed In Circuit Emulator MPLAB IDE 로사용가능 dspic & PIC18Fxxx 지원 USB & Parallel Interface Low-voltage 에서동작가능 -1.8V 64K deep Trace Memory 2MB 까지 Address 가능실시간으로데이터메모리체크 Stopwatch timer 66Mhz 클럭스피드 Slide 67
제한없는프로그램브레이크포인트 읽기, 쓰기, 브레이크, 트리거가가능한데이터메모리 개별적인트리거 (4) Individual Trigger Events 설정가능한 32Khz~25 Mhz 시스템클럭 프로그램 / 데이터메모리를위한 32K 트레이스버퍼 MPLAB-ICE 2000 In Circuit Emulator Slide 68
MPLAB IDE 환경에서지원 Stand-alone 동작양산용프로그래머내부에 ICSP 를내장하고있으며외부에이를위한포트지원함빠른프로그래밍모든디바이스지원함필드에서펌웨어업그래이드가능함 USB and RS-232 Interfaces 넓은 graphical LCD display 노이즈환경시 Buzzer 알람 PRO MATE 3 Universal Programmer Slide 69
PRO MATE II Universal PROGRAMMER MPLAB IDE Compatible Supports: ICSP ALL 8-bit MCUs Serial EEPROM Security Products Slide 70
In-Circuit Debugger ICD 2 MPLAB 에서사용 Firmware 업그레이드가능 디버거 / 프로그래머 스텝디버깅가능 브레이크포인트디버깅 USB 인터페이스 저렴한가격대 Slide 71
ICD2 (DV164005, DV164006,DV164007) To PC ICD for 8/14 Pin Devices ICD2 Header (AC162050) ICD Device (PIC12F675/ICD) Target Board Slide 72
SEEVAL 32 DV243002 Microchip 모든 Serial EEPROM DIP Pkg 지원 Read, write, erase Windows XP, ME, 2000, NT 에서동작됨 Power supply, RS-232, sample pack Slide 73
PICkit TM 2 & 8/14/20-Pin Flash Demo Board ICSP 기능을이용한전디바이스 (PIC/PIC24/dsPIC30/dsPI C33) Programming 가능 USB 인터페이스 8/14/20 Pin MCU 를이용하여 LED 4ea, SW, 가변저항을이용할수있는데모보드구성향후 Stand-alone Programming 지원향후지속적인 Software 업그레이드가능 ( www.microchipkorea.co.k r ) Slide 74
Third Party Tools Beyond Microchip s own tools... there are over 100 third-party companies supporting Microchip products DS00104 Slide 75
MPLAB IDE & PICKIT2 사용법 Slide 76
MPLAB IDE 사용법 ( Project Wizard 이용 ) 프로젝트를만드는가장쉬운방법으로 MPLAB IDE 의 Project Wizard 를이용 Project 메뉴에서 project Wizard 를선택 Slide 77
MPLAB IDE 사용법 ( Project Wizard 이용 ) Welcome! 페이지 Slide 78
MPLAB IDE 사용법 ( Project Wizard 이용 ) Step 1 : 사용하고자하는소자를선택 Slide 79
MPLAB IDE 사용법 ( Project Wizard 이용 ) Step 2 : 사용하고자하는언어를선택. Toolsuite selector Programs in toolsuite Location of toolsuite Slide 80
MPLAB IDE 사용법 ( Project Wizard 이용 ) 모든 Microchip 언어와인터페이스가가능한 Third party 언어가표시됨. 자동으로언어의위치지정이되지않을때 Browse 버튼을사용하여위치를지정 Third party 의언어가리스트되지않을때 Help 참조 Slide 81
MPLAB IDE 사용법 ( Project Wizard 이용 ) 만약 Third party 언어를선택했을때 MPLAB IDE 에그위치가지정되지않았을때에는적색의 X 자를표시. Third party 언어선택 MPLAB IDE 가선택된언어의위치를모름을표시 Browse 버튼을사용수동으로위치설정 Slide 82
MPLAB IDE 사용법 ( Project Wizard 이용 ) Step 3 : 프로젝트명과경로지정 ( 프로젝트파일과소스코드는같은폴더에있어야함. ) 경로명에는한글이포함되면안되며, 폴더가바탕화면에있으면안됨. Slide 83
MPLAB IDE 사용법 ( Project Wizard 이용 ) Step 4 : 필요한소스코드를선택하여 Add 를선택. 링커나헤더가필요하다면함께선택 Slide 84
MPLAB IDE 사용법 ( Project Wizard 이용 ) final step : 현 Project 에대한정보 Finish 버튼을누름 Slide 85
PICkit TM 2 Hardware 1. Power LED : USB 포트를통해 PICkit 2 프로그래머에전원공급이되는지알려줌. 2. Target LED : PICkit 2 프로그래머가 Target 마이컴에전원공급중임을알려줌. 3. Busy LED : PICkit 2 프로그래머가프로그래밍과같은기능수행중임을알려줌. 4. Push 버튼 : PICkit 2 프로그래머기능초기화. 5. USB 포트연결 6. PIC18F2550 Full Speed USB 마이컴 7. 6 핀프로그래밍컨넥터 : Target 마이컴에연결되는 6 핀컨넥터로 ICSP (In- Circuit Serial Programming ) 방식으로프로그래밍됨. Slide 86
PICkit 2 Software 사용법 Step 1 : Program StartPICkit 2 프로그래밍소프트웨어시작 PICkit 2 프로그래밍소프트웨어는시작 > 모든프로그램 > PICkit2> PICkit 2 를선택하여실행합니다. 그러면다음그림과같은윈도우창이뜹니다. Manu Bar Device Configuration Status Bar Progress Bar Program Memory EE Data Memory Slide 87
PICkit 2 Software 사용법 Step 2 : 디바이스패밀리선택 PICkit 2 프로그래머를사용하는첫번째단계는디바이스패밀리를선택하는것입니다. 아래그림에서보는바와같이 Menu Bar 에서 Device Family 를클릭하여디바이스패밀리를선택합니다. Step 3 : 디바이스식별 (Identification) Mid-range(14 bit core) 가선택되면 PICkit 2 프로그래머는자동으로마이컴으로부터디바이스 ID 를읽어서다음그림과같이 Configuration 창에 Target 디바이스를표시합니다. Slide 88
Step 4 : Target Power PICkit 2 Software 사용법 PICkit 2 프로그래머는 Target 보드로부터전원을공급받을수도있습니다. 이를위해서는아래그림과같이 Target Power Check Box 를클릭하여야합니다. Step 5 : Import HEX file 컴파일된코드 (HEX 파일 ) 를 Import 하기위해서는아래그림과같이 File>Import File 를선택합니다. 해당하는 HEX 파일을지정한후 Open 을클릭합니다. 해당코드는 Program Memory 창과 EE Data Memory 창에디스플레이됩니다. HEX 파일이름은 Source 블록에디스플레이됩니다. Slide 89
Step 5 : Write PICkit 2 Software 사용법 디바이스패밀리가선택되고 HEX 파일이 Import 되면 Write 버튼을클릭하여 Target PICmicro 마이컴에프로그래밍을할수있습니다. Write 동작의상태확인은 Device Configuration 창에위치한 Status Bar 를참조하시기바랍니다. 만약정상적으로 Write 동작이수행되었다면 Status Bar 는녹색으로변하고 Write Successful 이디스플레이됩니다. 만약 Write 동작에문제가발생되면 Status Bar 는적색으로변하고 Verify Failed 가디스플레이됩니다. 에러는프로그래밍수행중에데이터오류가발생되었음을의미합니다. Slide 90
Step 6 : PICkit2 Operating System 다운로드 PICkit 2 펌웨어다운로드는 Tools>Download PICkit2 Operating System 을선택합니다. 그러면다음그림과같은윈도우창이뜹니다. PK2V010001.HEX 파일을지정한후 Open 을클릭합니다. PICkit 2 Software 사용법 Slide 91
Hands-On Labs Slide 92
LAB 1 : Hello World ( MPLAB IDE & Compiler & PICKIT2 설치 ) Step 1 : MPLAB IDE 7.11 설치 ( Setup.exe ) Step 2 : RC0 ~ RC3 을출력설정 ( TRISC : 입력 ( 1 ), 출력 ( 0 ) ) - PIC16F630 & PIC16F676 사용을위한 Patch ( 해당파일 Copy ) Step 3 : PICKIT2 소프트웨어설치 (PICkit 2 Setup.EXE) Step 4 : LAB 폴더를 PICKIT2 가설치되어있는폴더로 Copy Step 5 : Project 생성 ( Project wizard 이용 ) 1. 사용하고자하는디바이스선택 ( PIC16F676 ) 2. 사용하고자하는언어선택 ( HI-TECH PICC Suite ) 3. Project 경로 ( \ 01 Hello World ) 및 Project 명 (Hello World ) 입력 4. 진행할 Program Source 추가 ( Hello World.c ) Step 6 : Project 를컴파일하여 Hex Code 생성 Step 7 : 생성된 Hex Code 를 PICKIT2 에다운로드 1. Target Power 채크 2. Import Hex File 3. Write Slide 93
LAB 1 : Hello World ( LED 켜기 ) VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 PIC16F 676 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6 Step 1 : RC0 ~ RC3 을출력설정 ( TRISC : 입력 ( 1 ), 출력 ( 0 ) ) Step 2 : PC0 ~ RC3 을 Turn On ( PORTC : On ( 1 ), Off ( 0 )) Slide 94
LAB 2 : Blink ( Time Delay 를이용한 LED ) VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 PIC16F 676 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6 Step 1 : < 02 Blink > Project 를생성한다. Step 2 : RC0 ~ RC3 을출력으로설정한다 ( TRISC : 입력 (1), 출력 (0)) Step 3 : RC0 ~ RC3 을 Turn On 한다. ( PORTC : On ( 1 ), Off ( 0 ) ) Step 4 : Delay( 약 500msec ) 구문을추가한다. Step 5 : RC0 ~ RC3 을 Turn Off 한다. ( PORTC : On ( 1 ), Off ( 0 ) ) Step 6 : Delay( 약 500msec ) 구문을추가한다. MPLAB IDE 의시뮬레이터기능을익힌다. -View 창을통하여 CPU 의상태를채크. - Break 기능과 Stopwatch 기능을이용하여 200msec Delay 구문추가 Slide 95
VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 LAB 3 : Rotate ( Time Delay 함수를이용한 LED 회전 ) PIC16F 676 Step 1 : < 03 Rotate > Project 를생성한다. Step 2 : RC0 ~ RC3 을출력으로설정한다 ( TRISC : 입력 (1), 출력 (0)) Step 3 : RC0 을 Turn On 한다. ( PORTC : On ( 1 ), Off ( 0 ) ) Step 4 : Delay_Routine() 을호출한다.( ( 약 500msec ) 구문을추가한다. Step 5 : PORTC Shift 시킨다. Step 6 : 만약 RC3 이 Turn On 되었으면, RC0 를 Turn On 시킨다. C 언어의기본문법을익혀보자. - 수의표현방법 - 서브루틴호출방법 - 각종연산자의의미 Slide 96 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6
LAB 4 : A2D ( AD 변환후 AD 값 LED Display ) 5V VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 PIC16F 676 Step 1 : < 04 A2D > Project 를생성한다. Step 2 : RA0 를아날로그포트로설정 ( ADSEL : Analog (1), Digital (0) ) Step 3 : ANCON0 Register 를설정한다 - Left justified, VR = VDD, AD Channel : AN0, ADON Step 4 : ANCON1 Register 를설정한다. - AD Conversion Clock = Fosc/2 Step 5 : RA0 를입력으로설정한다. Step 6 : Sampling Hold Time Delay 를준다. Step 7 : AD Conversion 을시작한다.( GODONE bit = On ) Step 8 : AD Conversion 이끝날때까지기다린다 ( GODONE bit = Off ) Step 9 : AD 결과값상위 4bit 를 RC0 ~ RC3 LED Port 에 Display 한다. Slide 97 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6
LAB 4 : A2D ( ADC Block Diagram ) Slide 98
ADCON Register LAB 4 : A2D ( AD 관련 Register ) ADCON1 Register Slide 99
5V VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 LAB 5 : Debounce PIC16F 676 ( SW 입력에따른 LED 제어 ) VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6 Step 1 : < 05 Debounce > Project 를생성한다. Step 2 : RA3 를입력포트로설정 ( RA3 : Input (1), Output (0) ) Step 3 : RC0 포트를 Output 으로설정하고, Turn On 시킨다. Step 4 : 200mSec Delay 실행 Step 5 : 200mSec 마다 LED 를좌회전시킨다. Step 6 : 만약 RA3 SW 가 1 초동안 Low 이면 LED 방향을바꾼다. Slide 100
5V VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 LAB 6 : Timer0 ( Timer0 Delay 를이용한 LED 제어 ) PIC16F 676 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6 Step 1 : < 06 Timer0 > Project 를생성한다. Step 2 : RC0 포트를 Output 으로설정하고, Turn On 시킨다. Step 3 : Timer0 를설정한다. ( OPTION Register ) - TMR0 Clock Source = Internal, Prescaler = TMR0, Rate = 1:256 Step 4 : T0IF 가 Set 되었는지채크한다. Step 5 : 만약 T0IF 가 Set 되었다면, T0IF 를클리어시킨다. Step 6 : LED Port 를좌회전시킨다. Slide 101
LAB 6 : Timer0 ( Timer0 Block Diagram ) Slide 102
LAB 6 : Timer0 ( OPTION Register ) Slide 103
5V VDD GP5/T1CKI/OSC1/CLKIN GP4/AN3/T1G/OSC2/CLKOUT VDDGP3/MCLR/VPP RC5 RC4 RC3 LAB 7 : Interrupt ( Timer0 Interrupt Delay 를이용한 LED 제어 ) PIC16F 676 VSS GP0/AN0/CIN+/ICSPDAT GP1/AN1/CIN-/ICSPCLK GP2/AN2/T0CKI/INT/COUT RC0/AN4 RC1/AN5 RC2/AN6 Step 1 : < 07 Interrupt > Project 를생성한다. Step 2 : RC0 포트를 Output 으로설정하고, Turn On 시킨다. Step 3 : Timer0 를설정한다. ( OPTION Register ) - TMR0 Clock Source = Internal, Prescaler = TMR0, Rate = 1:256 Step 4 : Interrupt 를설정한다 ( INTCON Register ) - GIE bit = Set, T0IE = Set Step 5 : Interrupt Service Routine 에서 Timer0 Interrupt 가발생했는지채크한다. ( T0IF ) Step 6 : Timer0 Interrupt 가발생했다면 T0IF 를 Clear 하고, LED 를좌회전시킨다. Slide 104
LAB 7 : Interrupt ( Interrupt Logic ) Slide 105
LAB 7 : Interrupt ( INCON Register ) Slide 106
PICKIT2 Demoboard Schematic Slide 107