NEC单片机 UPD78F9234 16位定时器使用例程(汇编)
时间:11-27
来源:互联网
点击:
NEC单片机 UPD78F9234 16位定时器使用例程(汇编)
;*************************************************
; Lable def
;*************************************************
LED8_MODE EQU PM2.1
LED7_MODE EQU PM2.0
LED6_MODE EQU PM12.0
LED5_MODE EQU PM0.3
LED4_MODE EQU PM0.2
LED3_MODE EQU PM0.1
LED2_MODE EQU PM0.0
LED1_MODE EQU PM12.3
LED8 EQU P2.1
LED7 EQU P2.0
LED6 EQU P12.0
LED5 EQU P0.3
LED4 EQU P0.2
LED3 EQU P0.1
LED2 EQU P0.0
LED1 EQU P12.3
;=========================(debug resource)======================================={
;*************************************************
; VAR DEF
;*************************************************
DATA_SEGMENT1 DSEG SADDR ; (AT 0FE20H)
VAR_1: DS 1
ORG 018H
DB 0FFH,0FFH;
ORG 07EH
DB 0FFH,0FFH;
ORG 81H
DB 0FFH;
ORG 01ED0H
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0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
;=================================================================================
;*************************************************
;INTERRUPT VECT
;*************************************************
ORG 0000H
DW START_PROGRAM
ORG 000EH
DW INTTM000_VECT
;*************************************************
;CODE
;*************************************************
CSEG ;(AT XXXXH)
START_PROGRAM:
DI
MOVW AX,#0FE20H;
MOVW SP,AX;
MOV PCC,#00H;
MOV PPCC,#00H;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
MOV PMC2,#00H
MOV PM2,#0FFH
; SET TM00
MOV TMC00,#00H
MOV PRM00,#02H ;31.25KHz 32us
MOVW AX,#31250;9800 ;313.6ms 15625
MOVW CR000,AX
CLR1 TMIF000 ;clear sign
CLR1 TMMK000 ;allow interrupt
MOV TMC00,#0CH ;clear the CR000 when TM00=CR000
EI
CLR1 LED1_MODE
CLR1 LED2_MODE
CLR1 LED3_MODE
CLR1 LED4_MODE
CLR1 LED5_MODE
CLR1 LED6_MODE
CLR1 LED7_MODE
CLR1 LED8_MODE
SET1 LED1
SET1 LED2
SET1 LED3
SET1 LED4
SET1 LED5
SET1 LED6
SET1 LED7
SET1 LED8
CLR1 LED1
MAIN:
MOV WDTE,#0ACH;
BR !MAIN
;*************************************************
; SUB PROGRAM
;*************************************************
CSEG
DELAY_1MS:
MOV B,#0FFH
BBBB:
DBNZ B,$BBBB;
RET
;*************************************************
;INTERRUPT FUNCTION
;*************************************************
CSEG
INTTM000_VECT:
BT LED1,$LED22 ;jump if LED1=1
SET1 LED1
CLR1 LED2
BR !backtrack
LED22:
BT LED2,$LED33
SET1 LED2
CLR1 LED3
BR !backtrack
LED33:
BT LED3,$LED44
SET1 LED3
CLR1 LED4
BR !backtrack
LED44:
BT LED4,$LED55
SET1 LED4
CLR1 LED5
BR !backtrack
LED55:
BT LED5,$LED66
SET1 LED5
CLR1 LED6
BR !backtrack
LED66:
BT LED6,$LED77
SET1 LED6
CLR1 LED7
BR !backtrack
LED77:
BT LED7,$LED88
SET1 LED7
CLR1 LED8
BR !backtrack
LED88:
BT LED8,$INTTM000_VECT
SET1 LED8
CLR1 LED1
BR !backtrack
backtrack:
RETI
END
;*************************************************
; Lable def
;*************************************************
LED8_MODE EQU PM2.1
LED7_MODE EQU PM2.0
LED6_MODE EQU PM12.0
LED5_MODE EQU PM0.3
LED4_MODE EQU PM0.2
LED3_MODE EQU PM0.1
LED2_MODE EQU PM0.0
LED1_MODE EQU PM12.3
LED8 EQU P2.1
LED7 EQU P2.0
LED6 EQU P12.0
LED5 EQU P0.3
LED4 EQU P0.2
LED3 EQU P0.1
LED2 EQU P0.0
LED1 EQU P12.3
;=========================(debug resource)======================================={
;*************************************************
; VAR DEF
;*************************************************
DATA_SEGMENT1 DSEG SADDR ; (AT 0FE20H)
VAR_1: DS 1
ORG 018H
DB 0FFH,0FFH;
ORG 07EH
DB 0FFH,0FFH;
ORG 81H
DB 0FFH;
ORG 01ED0H
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH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
;*************************************************
;INTERRUPT VECT
;*************************************************
ORG 0000H
DW START_PROGRAM
ORG 000EH
DW INTTM000_VECT
;*************************************************
;CODE
;*************************************************
CSEG ;(AT XXXXH)
START_PROGRAM:
DI
MOVW AX,#0FE20H;
MOVW SP,AX;
MOV PCC,#00H;
MOV PPCC,#00H;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
CALL !DELAY_1MS;
MOV PMC2,#00H
MOV PM2,#0FFH
; SET TM00
MOV TMC00,#00H
MOV PRM00,#02H ;31.25KHz 32us
MOVW AX,#31250;9800 ;313.6ms 15625
MOVW CR000,AX
CLR1 TMIF000 ;clear sign
CLR1 TMMK000 ;allow interrupt
MOV TMC00,#0CH ;clear the CR000 when TM00=CR000
EI
CLR1 LED1_MODE
CLR1 LED2_MODE
CLR1 LED3_MODE
CLR1 LED4_MODE
CLR1 LED5_MODE
CLR1 LED6_MODE
CLR1 LED7_MODE
CLR1 LED8_MODE
SET1 LED1
SET1 LED2
SET1 LED3
SET1 LED4
SET1 LED5
SET1 LED6
SET1 LED7
SET1 LED8
CLR1 LED1
MAIN:
MOV WDTE,#0ACH;
BR !MAIN
;*************************************************
; SUB PROGRAM
;*************************************************
CSEG
DELAY_1MS:
MOV B,#0FFH
BBBB:
DBNZ B,$BBBB;
RET
;*************************************************
;INTERRUPT FUNCTION
;*************************************************
CSEG
INTTM000_VECT:
BT LED1,$LED22 ;jump if LED1=1
SET1 LED1
CLR1 LED2
BR !backtrack
LED22:
BT LED2,$LED33
SET1 LED2
CLR1 LED3
BR !backtrack
LED33:
BT LED3,$LED44
SET1 LED3
CLR1 LED4
BR !backtrack
LED44:
BT LED4,$LED55
SET1 LED4
CLR1 LED5
BR !backtrack
LED55:
BT LED5,$LED66
SET1 LED5
CLR1 LED6
BR !backtrack
LED66:
BT LED6,$LED77
SET1 LED6
CLR1 LED7
BR !backtrack
LED77:
BT LED7,$LED88
SET1 LED7
CLR1 LED8
BR !backtrack
LED88:
BT LED8,$INTTM000_VECT
SET1 LED8
CLR1 LED1
BR !backtrack
backtrack:
RETI
END
- 单片机智能频率信号装置(11-25)
- 单片机在医学信号检测仪中的应用(02-07)
- 单片机应用编程技巧(02-25)
- DSP与单片机通信的多种方案设计(03-08)
- 单片机与PC机串行通信的实现方法 (02-25)
- 单片机与PC通信的简化接口 (05-11)