我现在用PIC做定时中断时,软件调试没有问题,可是烧写后没有出现应有的中断,程序如下:
ORG 0X00
GOTO START
ORG 0X04
GOTO INT
ORG 0X50
START
MOVLW B'10101010'
MOVWF FLAG1
BANKSEL TRISB
BCF TRISB,1
BANKSEL OPTION_REG
MOVLW B'10000000'
OPTION
BANKSEL PIE1
BSF PIE1,0
BANKSEL INTCON
MOVLW 0C0H
MOVWF INTCON
BANKSEL T1CON
MOVLW B'00110100'
MOVWF T1CON
MOVLW 50H
MOVWF TMR1H
MOVWF TMR1L
LOOP
BSF T1CON,0
GOTO LOOP
INT
BANKSEL PIR1
BCF PIR1,TMR1IF
BANKSEL PORTB
BTFSS PORTB,1
GOTO SET1
BCF PORTB,1
GOTO START
SET1
BSF PORTB,1
GOTO START
END
就是用RB1来反映是否执行中断,但是这个程序运行后RB1只是低电平,不知什么地方出问题了,希望各位老大不吝赐教,谢谢
请教:关于PIC定时中断
全部回复(2)
正序查看
倒序查看
现在还没有回复呢,说说你的想法
你的程序很乱,中断返回没有,有可能陷入死循环.我把修改后的代码给你.你的系统初始化我没有改动.我没有查询,如果可能你最好用c编写. ORG 0X00
GOTO mainline
ORG 0X04
GOTO INT
ORG 0X50
mainline
call initial
BSF T1CON,0
mainloop
GOTO mainloop
initial
MOVLW B'10101010'
MOVWF 20
BANKSEL TRISB
BCF TRISB,1
BANKSEL OPTION_REG
MOVLW B'10000000'
OPTION
BANKSEL PIE1
BSF PIE1,0
BANKSEL INTCON
MOVLW 0C0H
MOVWF INTCON
BANKSEL T1CON
MOVLW B'00110100'
MOVWF T1CON
MOVLW 50H
MOVWF TMR1H
MOVWF TMR1L
return
INT
BANKSEL PIR1
BCF PIR1,TMR1IF
MOVLW 50H
MOVWF TMR1H
MOVWF TMR1L
BANKSEL PORTB
BTFSS PORTB,1
GOTO SET1
BCF PORTB,1
retie
SET1
BSF PORTB,1
retie
END
GOTO mainline
ORG 0X04
GOTO INT
ORG 0X50
mainline
call initial
BSF T1CON,0
mainloop
GOTO mainloop
initial
MOVLW B'10101010'
MOVWF 20
BANKSEL TRISB
BCF TRISB,1
BANKSEL OPTION_REG
MOVLW B'10000000'
OPTION
BANKSEL PIE1
BSF PIE1,0
BANKSEL INTCON
MOVLW 0C0H
MOVWF INTCON
BANKSEL T1CON
MOVLW B'00110100'
MOVWF T1CON
MOVLW 50H
MOVWF TMR1H
MOVWF TMR1L
return
INT
BANKSEL PIR1
BCF PIR1,TMR1IF
MOVLW 50H
MOVWF TMR1H
MOVWF TMR1L
BANKSEL PORTB
BTFSS PORTB,1
GOTO SET1
BCF PORTB,1
retie
SET1
BSF PORTB,1
retie
END
0
回复
提示
@xxy1990
你的程序很乱,中断返回没有,有可能陷入死循环.我把修改后的代码给你.你的系统初始化我没有改动.我没有查询,如果可能你最好用c编写. ORG0X00 GOTOmainline ORG0X04 GOTOINT ORG0X50mainline call initial BSFT1CON,0mainloop GOTO mainloopinitial MOVLWB'10101010' MOVWF20 BANKSELTRISB BCFTRISB,1 BANKSELOPTION_REG MOVLWB'10000000' OPTION BANKSELPIE1 BSFPIE1,0 BANKSELINTCON MOVLW0C0H MOVWFINTCON BANKSELT1CON MOVLWB'00110100' MOVWFT1CON MOVLW50H MOVWFTMR1H MOVWFTMR1L return INT BANKSELPIR1 BCFPIR1,TMR1IF MOVLW50H MOVWFTMR1H MOVWFTMR1L BANKSELPORTB BTFSSPORTB,1 GOTOSET1 BCFPORTB,1 retieSET1 BSFPORTB,1 retie END
佩服!您是真正的学者.
0
回复
提示