|
楼主 |
发表于 2005-4-11 13:13:12
|
显示全部楼层
中断部分程序
.org 0x013
;Time2比较中断 ;滤波器,定时400KHz
OC2Handler:
ldi temp5,CLoseTCCR2 ;关闭滤波
out TCCR2,temp5
sbi ACSR,ACI
sbi ACSR,ACIE ;打开比较中断
reti
;模拟比较器中断
ANA_COMPHandler:
cbi PORTD,5
sbic ACSR,ACO
sbi PORTD,5
in backupSREGComp,SREG
add CompCount0,Const_1
adc CompCount1,Const_0
adc CompCount2,Const_0
out SREG,backupSREGComp
cbi ACSR,ACIE ;关闭比较中断,进行滤波
ldi temp5,InitTCCR2 ;打开滤波
out TCCR2,temp5
reti
;**** Time1 比较中断。1秒定时器
OC1AHandler:
mov CountDataBuffer0,CompCount0
clr CompCount0
sei
mov CountDataBuffer1,CompCount1
clr CompCount1
mov CountDataBuffer2,CompCount2
clr CompCount2
;************************************起振部分
tst CountDataBuffer0 ;CountDataBuffer(2)==0,PORTD5反转,起振
brne PORTD5TestEnd
tst CountDataBuffer1
brne PORTD5TestEnd
tst CountDataBuffer2
brne PORTD5TestEnd
push temp0
ldi temp0,InitDDRD ;防止I/O脚干扰
out DDRD,temp0
;***** PORTD5反转 ***********
sbis PIND,5
rjmp PORTD5Set1
cbi PORTD,5
rjmp PORTD5SetEnd
PORTD5Set1:
sbi PORTD,5
PORTD5SetEnd:
;***** PORTD5反转 ********END
pop temp0
PORTD5TestEnd:
;************************************起振部分**END
ldi ActionFlag,CountDataReady
reti
M8的抗干扰能力很差,经常出现I/O无输出
-----此内容被GandF于2005-04-11,13:16:40编辑过
-----此内容被GandF于2005-04-11,13:26:09编辑过 |
|