控制/MCU
;I2C总线程序
;thisiseepromread&writeprogramm
;thespecialstoreramunit
wequ0
f0equ0
rtCCequ1
pcequ2
f2equ2
f3equ3
f4equ4
raequ5
rbequ6
rcequ7
pclathequ0ah
iNTConequ0bh
pir1equ0ch
tmr1lequ0eh
tmr1hequ0fh
t1conequ10h
tmr2equ11h
t2conequ12h
sspbufequ13h
sspconequ14h
ccpr1lequ15h
ccpr1hequ16h
ccpconequ17h
adcon0equ1fh
;
;inthebank1
trISAequ85h
trisbequ86h
triscequ87h
pconequ8eh
pie1equ8ch
pr2equ92h
sspaddequ93h
sspstatequ94h
adcon1equ9fh
;
;--------------------------------------------------------
;thegenaralstoreramunit
;
temp6equ76h
temp7equ77h
;
eepCTRequ6dh;eepromcontrolwordsbuffer
eepaddrequ6eh;eepromaddressbuffer
eepdataequ6fh;eepromdatabuffer
;
;--------------------------------------------------------
;thebitsoframunit
sclequ3;rc
sdaequ4;rc
;
pdequ3;status
toequ4;status
;
rbifequ0;intcon
intifequ1;intcon
rtifequ2;intcon
rbieequ3;intcon
intieequ4;intcon
rtieequ5;intcon
adieequ6;intcon
gieequ7;intcon
;
;----------------------------------------------------------
;Thecontact
sda_inequ10h
sda_outequ00h
;
;----------------------------------------------------------
org000h
gotomain_program
;--------------------------------------------------------
;theson-programarea
;--------------------------------------------------------
org005h
;--------------------------------------------------------
make_s
bsfrc,sda
bsff3,5
;bsfrc,sda
MOVlwsda_out
MOVwftrisc
bcff3,5
nop
ack_check
bsff3,5
;bcfrc,sda
MOVlwsda_in
MOVwftrisc
bcff3,5
nop
m_start
bsfrc,scl
nop
btfssrc,sda
gotomake_s
m_start0
bsfrc,scl
bcfrc,sda
bsff3,5
;bsfrc,sda
MOVlwsda_out
MOVwftrisc
bcff3,5
MOVlw10100000b
btfscsign,read_b
MOVlw10100001b
MOVwf6dh
MOVlw6dh
MOVwff4
w_byte
bsff3,5
;bsfrc,sda
MOVlwsda_out
MOVwftrisc
bcff3,5
MOVlw08h
MOVwftemp2
bit_loop
nop
rlff0
bcfrc,scl
btfssf3,0
goto^+3
bsfrc,sda
goto^+2
bcfrc,sda
nop
bsfrc,scl
decfsztemp2
gotobit_loop
nop
bcfrc,scl
bsff3,5
;bcfrc,sda
MOVlwsda_in
MOVwftrisc
bcff3,5
bsfrc,scl
nop
btfscrc,sda
gotom_start0
bcfrc,scl
return
;
w_stop
m_stop
bcfrc,sda
bsff3,5
;bsfrc,sda
MOVlwsda_out
MOVwftrisc
bcff3,5
nop
bsfrc,scl
nop
bsfrc,sda
nop
bcfrc,scl
return
;
rd_bytes
nop
rnxtb
bcfrc,scl
bsff3,5
;bcfrc,sda
MOVlwsda_in
MOVwftrisc
bcff3,5
MOVlw08h
MOVwftemp2
rnx
bcfrc,scl
nop
bcff3,0
btfscrc,sda
bsff3,0
rlff0
bsfrc,scl
nop
decfsztemp2
gotornx
incff4,1
bsff3,5
;bsfrc,sda
MOVlwsda_out
MOVwftrisc
bcff3,5
bcfrc,scl
decfsztemp4
gotot_ackg
r_stop
gotom_stop
t_ackg
bcfrc,sda
nop
bsfrc,scl
nop
gotornxtb
;-----------------------------
delay_1ms
MOVlw.1
MOVwftemp6
delay_publIC
MOVlw.223
MOVwftemp7
public_2
clrwdt
decfsztemp7,1
gotopublic_2
decfsztemp6,1
gotodelay_public
return
;-----------------------------
;-----------------------------
;themainprogramarea
;-----------------------------
main_program
bsff3,5
MOVlw0fh
MOVwf81h
MOVlwsda_in
MOVwftrisc
bcff3,5;bank0
reset_delay
MOVlw20h
MOVwff4
next
clrff0
incff4,1
MOVlw80h;clr20h--7fhram
clrz
xorwff4,w
skpz
gotonext
;-----------------------
clrfintcon
bsff3,5
MOVlw0fh
MOVwf81h
bcff3,5;bank0
;
;---------------------------
read_eeprom_repair
bcfrc,eneep
calldelay_1ms
;
callack_check
MOVfaddress,0
MOVwf6eh
incff4
callw_byte
bsfsign,read_b
callack_check
bcfsign,read_b
MOVlw20h
MOVwff4
MOVlw.8
MOVwftemp4
callrd_bytes
nop
nop
nop
nop
calldelay_1ms
bsfrc,eneep
;
write_eeprom_repair
bcfrc,eneep
calldelay_1ms
;
callack_check
MOVfaddress,0
MOVwf6eh
incff4
callw_byte
MOVlw40h
MOVwff4
MOVlw.8
MOVwftemp4
write_option
callw_byte
incff4,1
decfsztemp4
gotowrite_option
callw_stop
nop
nop
nop
nop
calldelay_1ms
bsfrc,eneep
;
loop
gotoloop
end
全部0条评论
快来发表一下你的评论吧 !