当前位置:首页 > 单片机 > 单片机
[导读] include"P12c509a.inc"__CONFIGh’000E’;CPoff,WDTon,internalcLOCkDCConequ0Ovl_inequ1Relayequ2Ovl_outequ4CBLOCK0x0007state;statesequencetime0;counter0time1;counter1time2;counter2ENDCorg0M

include"P12c509a.inc"
__CONFIGh’000E’;CPoff,WDTon,internalcLOCk


DCConequ0
Ovl_inequ1
Relayequ2
Ovl_outequ4

CBLOCK0x0007
state;statesequence
time0;counter0
time1;counter1
time2;counter2
ENDC
org0
MOVwfOSCCAL;setcal
bcfSTATUS,PA0
MOVlwB’10001111’
option

;GP0DCCON/OFF(hiisON);;;;;;GP1isoverloadinput(activelo)
;GP2Reverseoutput;;;;;;;;GP4overloadoutput(HIisoverload)
;-----------------------------
MOVlwB’00000010’
trisGPIO
MOVlwB’00000001’;setports
MOVwfGPIO
clrfstate
;mainloopstartshere.SCANsforhionoverload.

testclrwdt
btfssGPIO,Ovl_in;lookforoverload
gotoset1

test1btfscstate,0;checkstate
gotocaltim;resetdelay

gototest;lookagain

;hereiftrueoverload

set1bcfGPIO,DCCon;turnoff
btfscstate,0;0iffirsttimeafterreset
gotostate1
bsfstate,0;settostate1

MOVfGPIO,W;getportsetting
xorlwB’00000100’;reverserelay
MOVwfGPIO

calldely25;delay25millisecsforrelay
bsfGPIO,DCCon;turnbackon
gototest;lookforoverload

state1bsfGPIO,Ovl_out;setalarm
calldel500
bsfstate,7;settimeout
bcfGPIO,Ovl_out;alarmoff
bsfGPIO,DCCon;outputon
gototest

caltimcalltimout;resettimer
gototest

delayMOVlw0xFF;shortdelay
MOVwftime0
delay1clrwdt
nop
nop
decfsztime0,F
gotodelay1
retlw0

dely25clrwdt
MOVlw.30;25millisecs
MOVwftime1
del25aMOVlw0xFF
MOVwftime2
del25bdecfsztime2,F
gotodel25b
decfsztime1,F
gotodel25a
retlw0

del500MOVlw0xFF;500millisecs
MOVwftime1
del500aMOVlw0xFF
MOVwftime2
del500bclrwdt
nop
nop
nop
nop
decfsztime2,F
gotodel500b
decfsztime1,F
gotodel500a
retlw0

timoutbtfssstate,7;continuecountdown
gotocountdn
MOVlw0xFF;setcounters
MOVwftime1
timo2MOVlw0xFF
MOVwftime2
bcfstate,7
countdndecfsztime2,F
retlw0
decfsztime1,F
gototimo3
clrfstate;reset
retlw0

timo3MOVlw0xFF
MOVwftime2
retlw0

end


本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭