- UID
- 1023166
- 性别
- 男
- 来自
- 燕山大学
|
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,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,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,0FFH,0FFH,0FFH,0FFH
;=================================================================================
;*************************************************
;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
UPD78F9234产品参数:
MCU 8BIT 8KB FLASH 30PIN
核心处理器:78K0S
芯体尺寸:8-位
速度:10MHz
连通性:LIN,UART/USART
外围设备:LVD, POR, PWM, WDT
输入/输出数:24
程序存储器容量:8KB (8K x 8)
程序存储器类型:FLASH
EEPROM 大小:-
RAM 容量:256 x 8
电压 - 电源 (Vcc/Vdd):2 V ~ 5.5 V
数据转换器:A/D 4x10b
振荡器型:内部
工作温度:-40°C ~ 85°C |
|