44-Pin Demo Board User’s Guide
3.2.1
Lesson 1: Hello World (Light a LED)
The first lesson shows how to turn on a LED. This is the PIC ? microcontroller version
of “Hello World” and discusses the I/O pin structures.
New Instructions
BSF
BCF
Bit set
Bit clear
The LEDs are connected to I/O pins RD0 through RD7. When one of these I/O pins
drives high, the LED turns on. The I/O pins can be configured for input or output. On
start-up, the default is input. The TRIS Special Function Register bits use the conven-
tion of ‘ 0 ’ for output and ‘ 1 ’ for input. We want digital output so these must be
configured.
EXAMPLE 3-1:
PICKIT 2, LESSON 1: “HELLO WORLD”
; PICkit 2 Lesson 1 - "Hello World"
;
#include <p16F887.inc>
__CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF &
_BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF &
_PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
org 0
Start:
BSF
BCF
BCF
BSF
GOTO
STATUS,RP0
TRISD,0
STATUS,RP0
PORTD,0
$
;
;
;
;
;
select Register Bank 1
make IO Pin RD0 an output
back to Register Bank 0
turn on LED RD0 (DS0)
wait here
END
Now lets look at the program that makes this happen.
DS41296B-page 14
;
#include
__Config
Org 0
BCF TRISC,0
BSF PORTD,0
GOTO $
Starts a comment. Any text on the line following the semicolon
is ignored.
Brings in an include file defining all the Special Function Regis-
ters available on the PIC16F887. Also, it defines valid memory
areas. These definitions match the names used in the device
data sheet.
Defines the Configuration Word. The labels are defined in the
p16F887.inc file. The labels may be logically ANDed
together to form the word.
Tells the assembler where to start generating code. Code may
be generated for any area of the part. Mid-range PIC ? micro-
controller devices start at address ‘ 0 ’, also called the Reset
vector.
Tells the processor to clear a bit in a file register. TRISD is the
tri-state register for pin 0 of PORTD. A ‘ 1 ’ in the register makes
the pin an input; a ‘ 0 ’ makes it an output. We want to make it an
output, so the bit must be cleared.
Tells the processor to set pin 0 of PORTD. This will force the I/O
pin to a high condition turning on the LED.
Tells the processor to go to the current instruction.
? 2007 Microchip Technology Inc.
相关PDF资料
DM240011 KIT STARTER MPLAB FOR PIC24F MCU
DM240021 KIT STARTER MPLAB FOR PIC24H
DM240311 BOARD DEV PIC24F16KA102 XLP
DM300018 BOARD DEMO DSPICDEM 2
DM300019 BOARD DEMO DSPICDEM 80L STARTER
DM300024 KIT DEMO DSPICDEM 1.1
DM330012 KIT USB STARTER FOR DSPIC33E
DM330013 MICROSTICK DSPIC33F/PIC24H BOARD
相关代理商/技术参数
DM240002 制造商:Microchip Technology Inc 功能描述:Explorer 16 kit(44-PIN) w/ PIC24FJ64GA00
DM240011 功能描述:开发板和工具包 - PIC / DSPIC MPLAB Starter Kit for PIC24F MCU RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM240012 功能描述:开发板和工具包 - PIC / DSPIC PIC24E USB Starter Kit RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM240013-1 功能描述:开发板和工具包 - PIC / DSPIC Microstick for 3V PIC24F K-series RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM240013-2 功能描述:开发板和工具包 - PIC / DSPIC RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压:
DM240014 制造商:Microchip Technology Inc 功能描述:MICROSTICK FOR USB PIC24F - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:ACCY MICROSTICK USB PIC24F 制造商:Microchip Technology Inc 功能描述:MICROSTICK USB PIC24F
DM240015 制造商:Microchip Technology Inc 功能描述:MPLAB STARTER KIT FOR PIC24F INTELLIGENT INTEGRATED ANALOG - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:KIT MPLAB STARTER FOR PIC24F ANL 制造商:Microchip Technology Inc 功能描述:PIC24F GC INTELLIGENT ANALOG DEV KIT 制造商:Microchip Technology Inc 功能描述:PIC24F, GC INTELLIGENT ANALOG, DEV KIT 制造商:Microchip Technology Inc 功能描述:Starter Kit for PIC24F Intelligent Integrated Analog Series 制造商:Microchip Technology Inc 功能描述:Development Boards & Kits - PIC / DSPIC 制造商:Microchip Technology Inc 功能描述:PIC24F, GC INTELLIGENT ANALOG, DEV KIT, Silicon Manufacturer:Microchip, Core Arc 制造商:Microchip Technology Inc 功能描述:PIC24F, GC INTELLIGENT ANALOG, DEV KIT, Silicon Manufacturer:Microchip, Core Architecture:PIC, Core Sub-Architecture:PIC24, Silicon Core Number:PIC24FJ128GC010, Silicon Family Name:PIC24FJxxxGCxxx, Kit Contents:Starter Board 制造商:Microchip Technology Inc 功能描述:MPLAB Starter Kit for PIC24F Intelligent Integrated Analog, Starter Kits
DM240021 功能描述:开发板和工具包 - PIC / DSPIC MPLAB STARTER KIT FOR PIC24H RoHS:否 制造商:Microchip Technology 产品:Starter Kits 工具用于评估:chipKIT 核心:Uno32 接口类型: 工作电源电压: