PIC16f877设计一个定时的程序 用汇编语言谢谢大侠
1个回答
展开全部
LIST P=16f627A,R=DEC
#include"p16F627A.inc"
;//////////////////////////////////////
cblock 0x0020
W_TEMP_BUF
STATUS_TEMP_BUF
FSR_TEMP_BUF
endc
org 0x0
nop
goto main
ORG 0X0004
MAINif ;RS INF
MOVWF W_TEMP_BUF ; W_TEMP is in virtual bank
SWAPF STATUS,0
BCF STATUS,RP0 ;CHANG TO BANK 0
MOVWF STATUS_TEMP_BUF ; STATUS_TEMP located anywhere
MOVF FSR,0
MOVWF FSR_TEMP_BUF
call time0_dispose ;rs dispose
MOVF FSR_TEMP_BUF,0
MOVWF FSR ; Restore FSR
;/////////////////////////
SWAPF STATUS_TEMP_BUF,W
MOVWF STATUS ; Restore STATUS
;/////////////////////////
SWAPF W_TEMP_BUF,F
SWAPF W_TEMP_BUF,W ; Restore WREG
RETFIE ; NO CHANG STATUS BIT
;/////////// inif dispose end //////////////////
time0_dispose
nop
movlw 0xfe
movwf TMR0
bcf intcon,2 ;clr if
return
main
CLRF TMR0 ; Clear Timer0 register
movlw 0xfe
movwf TMR0
CLRF INTCON ; Disable interrupts and clear T0IF
BSF STATUS, RP0 ; Bank1
MOVLW 0xC3 ; PortB pull-ups are disabled,
MOVWF OPTION_REG ; Interrupt on rising edge of RB0
BCF STATUS, RP0 ; Bank0
BSF INTCON, T0IE; Enable TMR0 interrupt
BSF INTCON, GIE ; Enable all interrupts
loop
nop
goto $
goto loop
end
#include"p16F627A.inc"
;//////////////////////////////////////
cblock 0x0020
W_TEMP_BUF
STATUS_TEMP_BUF
FSR_TEMP_BUF
endc
org 0x0
nop
goto main
ORG 0X0004
MAINif ;RS INF
MOVWF W_TEMP_BUF ; W_TEMP is in virtual bank
SWAPF STATUS,0
BCF STATUS,RP0 ;CHANG TO BANK 0
MOVWF STATUS_TEMP_BUF ; STATUS_TEMP located anywhere
MOVF FSR,0
MOVWF FSR_TEMP_BUF
call time0_dispose ;rs dispose
MOVF FSR_TEMP_BUF,0
MOVWF FSR ; Restore FSR
;/////////////////////////
SWAPF STATUS_TEMP_BUF,W
MOVWF STATUS ; Restore STATUS
;/////////////////////////
SWAPF W_TEMP_BUF,F
SWAPF W_TEMP_BUF,W ; Restore WREG
RETFIE ; NO CHANG STATUS BIT
;/////////// inif dispose end //////////////////
time0_dispose
nop
movlw 0xfe
movwf TMR0
bcf intcon,2 ;clr if
return
main
CLRF TMR0 ; Clear Timer0 register
movlw 0xfe
movwf TMR0
CLRF INTCON ; Disable interrupts and clear T0IF
BSF STATUS, RP0 ; Bank1
MOVLW 0xC3 ; PortB pull-ups are disabled,
MOVWF OPTION_REG ; Interrupt on rising edge of RB0
BCF STATUS, RP0 ; Bank0
BSF INTCON, T0IE; Enable TMR0 interrupt
BSF INTCON, GIE ; Enable all interrupts
loop
nop
goto $
goto loop
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询