参数资料
型号: DM240002
厂商: Microchip Technology
文件页数: 30/42页
文件大小: 0K
描述: BOARD DEV EXPLORER 16 44-PIN
标准包装: 1
系列: Explorer 16 44 引脚
类型: MCU
适用于相关产品: dsPIC30,dsPIC33,PIC32,PIC24FJ,PIC24HJ
所含物品: Explorer 16 开发板,PIC24FJ64GA004 和 dsPIC33FJ32GP204 PIM 模块
产品目录页面: 659 (CN2011-ZH PDF)
44-Pin Demo Board User’s Guide
3.2.8
Lesson 8: Function Calls
Lesson 8 shows the reversible LEDs but with the Delay Loop rewritten as a function.
New Instructions
CALL
RETURN
RETLW
Invokes functions or subroutines
Terminates functions or subroutines
Terminates functions or subroutines
Functions or Subroutines are invoked with the CALL instruction and terminated with
a RETURN or RETLW instruction. RETURN jumps back to the original program at the
location following the CALL . RETLW also returns to the calling program, but loads the
WREG with a constant.
The mid-range PIC ? microcontroller device’s CALL stack can hold up to 8 return
addresses.
If a ninth CALL is made, it will overwrite the first one and then the program will not be
able to RETURN all the way back.
Passing Arguments
Arguments to the subroutine may be passed in a number of ways. WREG is a conve-
nient place to pass one byte and the FSR may be used to pass another byte, if not oth-
erwise used. If more data must be passed, a buffer must be allocated.
When the Delay function is pulled out to a subroutine, the ADC result is moved into
WREG, then the CALL transfers control to the Delay subroutine. The RETURN trans-
fers control to the MOVLW following the CALL .
EXAMPLE 3-7:
FUNCTION CALL EXAMPLE
MOVF
ADDLW
CALL
ADRESH,w
1
Delay
;
;
;
;
;
Move conversion value (delay) to w
add 1 otherwise entering with 0 takes
longer than entering with 1.
Call delay function
returns here when done
...
GOTO
XXX
; Delay Function. Enter with number of 771uS delays in Wreg
Delay:
MOVWF Delay2
DelayLoop:
DECFSZ Delay1,f
GOTO DelayLoop
DECFSZ Delay2,f
GOTO DelayLoop
RETURN ; goes back to instruction after call
3.2.9
Lesson 9: Timer0
Timer0 is a counter implemented in the processor. It may be used to count processor
clock cycles or external events. Lesson 9 configures it to count instruction cycles and
set a flag when it rolls over. This frees up the processor to do meaningful work rather
than just counting cycles for a delay.
Timer0 is an 8-bit counter with an optional prescaler, which is configured to divide by
256 before reaching the Timer0 counter.
DS41296B-page 26
? 2007 Microchip Technology Inc.
相关PDF资料
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
相关代理商/技术参数
参数描述
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 接口类型: 工作电源电压: