Download FS982X IDE

Transcript
FS982X IDE
2.4.5 Writing Code
PT2 is setup to be an output port in this example, interrupt per second; ISR makes voltage of PT2 H/L output
in turn.
Select 『Assemble&Run->Edit Mode』to enter into writing code; in the meantime, to key in the following code
into the edit window as shown in the Figure 2.14.
PT2D
ORG
GOTO
ORG
GOTO
SYSINI:
CLKINI:
MOVLW
MOVWF
NOP
TIMERINI:
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
PT2INI:
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
MOVFW
MOVWF
equ
080h
00H
SYSINI
04H
TimerISR
; PT2D
00100001B
MCK
;Set CLK Source & Timer
00000000B
TMCON
10010000B
INTE
00001111B
TMCON
;reset Timer
00000000B
PT2PU
11111111B
PT2EN
11111111B
PT2D
PT2D
PT2
;Set Timer Interrupt Enable
;Set Timer
;Set pull-up resistor
;Set I/O Port
;Set PT2D data
;Set PT2 data
MAIN:
NOP
GOTO
TimerISR:
CLRF
COMF
MOVFW
MOVWF
RETFIE
END
MAIN
INTF
PT2D,1
PT2D
PT2
;Clear Timer Flag
;PT2 data invert
;Set PT2 data
Figure 2.14 Template code
Select 『Assemble&Run->Assemble&Run』to execute the code, the screen in the error message window will
show the Figure 2.15.
Figure 2.15 “Error Message” Window
Fortune Semiconductor Corp.
21/78
Rev. 1.0