;***********************
;This program demonstrates the need for context saving
;Port A not used. Port B bit 0 used for ext.interrupt ip.
#include P16f84A.inc
;
rhi equ 10
rlo equ 11
phi equ 12
plo equ 13
qhi equ 14
qlo equ 15
org 00
goto start
org 04
goto Int_Routine
;
start org 0010
bsf INTCON,INTE ; enable external interrupt
bsf INTCON,GIE ; enable glabal int
loop movlw 99
movwf phi ; preload numebers to be load
movwf plo
movwf qhi
movwf qlo
call Double_add
movlw 00 ; clear
movwf rhi
movwf rlo
goto loop
;This subroutine adds two 16-bit numbers, stored in phi-plo, and qhi-qlo,
;and stores result in rhi-rlo.
Double_add
movf plo,0
addwf qlo,0
movwf rlo
btfsc STATUS,0
incf phi,1 ; add in carry
movf phi,0
addwf qhi,0 ; add upper bytes
movwf rhi
return
Int_Routine
bcf STATUS,0 ; clear the carry flag
movlw 0ff ; change W reg value
bcf INTCON,INTE
retfie
end
本人是初学者,这个程序是一本书上的例题,我想问的是为什么程序开头没有定义port B端口的输入输出属性呢,此处只用到port B 0的输入属性,产生下降沿中断。是不是pic单片机的端口默认是输入模式吗?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
好像单片机的io口默认都是输出状态的,因为一上电,单片机io如果是输出的话,有可能与其他器件冲突,或者误动作
-----------------------------------------------------------------------
晕,写错了,默认是输入!
一周热门 更多>