LPC Demo Board Lessons
3.2.2
Lesson 2: Delay Loop (Blink a LED)
The first lesson showed how to turn on a LED, this lesson shows how to make it blink.
While this might seem a trivial change from Lesson 1, the reasons will soon become
apparent.
New Instructions
CLRF
INCF
DECF
INCFSZ
DECFSZ
GOTO
EXAMPLE 3-2:
Loop
Clear file register
Increment file register
Decrement file register
Increment file register, Skip next instruction if zero
Decrement file register, Skip next instruction if zero
Jump to a new location in the program
PICkit 2, LESSON 2: BLINK
BSF
BCF
GOTO
PORTC,0
PORTC,0
Loop
;turn on LED C0
;turn off LED C0
;do it again
While adding a BCF instruction and making it loop will make it blink, it will blink so fast
you won’t see it. It will only look dim. That loop requires 4 instruction times to execute.
The first instruction turns it on. The second one turns it off. The GOTO takes two instruc-
tion times, which means it will be on for 25% of the time.
As configured, the PICmicro executes 1 million instructions per second. At this rate, the
blinking needs to be slowed down so that the blinking can be seen, which can be done
by using a delay loop.
Note:
? 2005 Microchip Technology Inc.
Counting cycles – Relating clock speed to instruction speed. The processor
requires 4 clocks to execute an instruction. Since the internal oscillator as
used in these lessons runs at 4 MHz, the instruction rate is 1 MHz.
DS51556A-page 15
相关PDF资料
DM164120-3 BOARD DEMO PICKIT2 28-PIN
DM164120-5 BOARD DEMO PICKIT 2 64/80-PIN
DM164123 KIT MANAGEMENT SYSTEM PICDEM
DM180021 KIT STARTER MPLAB FOR PIC18F MCU
DM183022 BOARD DEMO PIC18FXX22 64/80TQFP
DM183032 BOARD EXPLORER PICDEM PIC18
DM240001 BOARD DEMO PIC24/DSPIC33/PIC32
DM240002 BOARD DEV EXPLORER 16 44-PIN
相关代理商/技术参数
DM164120-1 制造商:Microchip Technology Inc 功能描述:DEVELOPMENT TOOLS - PICKIT 2 LOW PIN COU
DM164120-2 功能描述:开发板和工具包 - PIC / DSPIC PICkit 2 44-Pin Count Demo Brd RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM164120-3 功能描述:开发板和工具包 - PIC / DSPIC PICkit 2 Count Demo Board RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM164120-4 功能描述:开发板和工具包 - PIC / DSPIC PICkit 2 1 Dem Board RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM164120-4 制造商:Microchip Technology Inc 功能描述:PICkit 2 18-Pin Demo Board
DM164120-4/16F1827/PG164130 制造商:Microchip Technology Inc 功能描述:PICKIT PIC16F648A DEMO BOARD 制造商:Microchip Technology Inc 功能描述:KIT STARTER 18PIN F1 ENHANCED CORE 制造商:Microchip Technology Inc 功能描述:PICKIT, PIC16F648A, DEMO BOARD 制造商:Microchip Technology Inc 功能描述:PICKIT, PIC16F648A, 18 PIN, DEMO BOARD; Silicon Manufacturer:Microchip; Core Architecture:PIC; Core Sub-Architecture:PIC16; Silicon Core Number:PIC16F; Silicon Family Name:PIC16F18xx; Kit Contents:Demo Board, 2x Bare PCB Boards
DM164120-5 功能描述:开发板和工具包 - PIC / DSPIC PICkit 2 64 demoBoard RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM164123 功能描述:开发板和工具包 - PIC / DSPIC PICDEM Sys Mgmt Board RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压: