本帖最后由 warm_ice 于 2010-1-18 16:38 编辑
;***************
;程序
;****************
ORG 0000H
JMP REST
RTNI
JMP TIMER0_ISP
JMP TIMER1_ISP
RTNI
;****************************
;TM0中断服务子程序
;****************************
TIMER0_ISP:
STA AC_BACK,00H
ANDIM IRQ,1011B
ORIM F_TIMER,0001B ;设置“5ms 到”标志
BA0 TIMER0_END
TIMER0_END:
ORIM IE,0110B
LDA AC_BACK,00H
RTNI
;****************************
; TM1中断服务子程序
;****************************
TIMER1_ISP:
STA AC1_BACK,00H
ANDIM IRQ,1101B
ORIM F_TIMER,0010B
EORIM PORTC,0010B
TIMER1_END:
LDI IE,0110B
LDA AC1_BACK,00H
RTNI
;****************
;上电初始化
;*****************
REST:
NOP
NOP
LDI DPL,00H
LDI DPM,03H
LDI DPH,00H
POWER_RESET_1:
LDI INX,00H
ADIM DPL,01H
LDI TEMP,00H
ADCM DPM,00H
BA3 POWER_RESET_2
JMP POWER_RESET_3
POWER_RESET_2:
ADIM DPH,01H
POWER_RESET_3:
SBI DPH,01H
BNZ POWER_RESET_1
SBI DPM,04H
BNZ POWER_RESET_1
CALL XTJCQ_IST ;初始化系统寄存器
XTJCQ_IST:
;PORT口初始化
LDI PORTA,00H
LDI PORTB,00H
LDI PORTC,0001B
LDI PORTD,0FH;打开上拉电阻使用低电平按键有效
LDI PORTE,00H
LDI PACR,0FH
LDI PBCR,0FH
LDI PCCR,1110B;输出口
LDI PDCR,1000B;输入口
LDI PECR,0FH
;TIMER初始化
LDI T0,00H;选择外部时钟
LDI TM0,07H
LDI T0L,00H
LDI T0H,00H
LDI TM1,00H;2048分频
LDI T1L,00H;timer1设置
LDI T1H,00H
LDI IE,0110B ;打开timer0、timer1中断
LOOP:
NOP
NOP
LDA WDT
JMP LOOP
你按上面的程序修改一下,然后测试PC.1口的波型.
END |