Title: Water
1?????e?e??t??
??a? ???sµ? p?? ?a µp????saµe ?a d?s??µe ??a t???
µ????e?e??t?? e??a? ? e??? ?????e?e??t?? e??a?
??a p????aµµat???µe?? ????????µ??? ?????µa t?
?p??? d?a??te? epe?e??ast?, µ??µ?, d??f??a
pe??fe?e?a?? ?????µata ?a??? ep?s?? ?a? ???e?
e?s?d??/e??d?? ??a ep????????a µe e??te?????
s?s?e???. Ta µp????se ?a pa??µ??aste? µe ??a?
µ?????p?????st?. ?p?? a???ß?? ??a?
µ?????p?????st?? ??e? epe?e??ast?,
µ??µ?, pe??fe?e?a??? s?s?e??? ?a? e?te?e?
p?????µµata ?ts? ?? ??a? µ????e?e??t?? d?a??te?
ta pa?ap??? ?a?a?t???st??? ?a? µ???sta
????????µ??a se ??a µ??? chip. ?? p????aµµa p??
e?te?e? ? µ????e?e??t?? ap????e?eta? µ???µa st?
µ??µ? p?????µµat??.
2?fa?µ???? µ????e?e??t??
?? µ????e?e??t?? ß??s???? efa?µ??? sta pa?a??t?
ped?a Se s?st?µata a?t?µat?sµ?? Se ?????µata
t??ep?????????? St?? ??e?t??????? s?s?e???
St?? ??e?t????? s?s?e??? Se s?st?µata
t??eµat???? Se s?st?µata s??????? ded?µ????
(Data Acquisition) Se efa?µ???? ??e?t???????
?s???? Se s?st?µata d?as??des?? Se efa?µ????
d??t??? Ge????te?a ?? µ????e?e??t??
???s?µ?p?????ta? ?p??d?p?te apa?te?ta? ??e????
s?st?µ?t??. ?ta? ??µe e?s?µat?µ??a s?st?µata
(Embedded Systems) e?????µe s?st?µata ta ?p??a
e??a? ßas?sµ??a se µ???oepe?e??ast? (? ep?s??
FPGA ? DSP)
3?atas?e?ast?? µ????e?e??t??
?p?????? de??de? eta??e?e? pa???sµ??? p??
?atas?e?????? µ????e?e??t??. ?? p?? d?aded?µ??e?
e??a? ?icrochip, www.microchip.com Atmel,
www.atmel.com Texas Instruments, www.ti.com
Freescale (p???? Motorolla), www.freescale.com
Intel, www.intel.com Analog Devices,
www.analog.com ?? pe??ss?te?e? eta??e?e? pa??????
µe???? ???µa µ????e?e??t??. ?p? p??? µ?????? ?a?
f?????? ??a ap??? efa?µ???? ??? ?d?a?te?a
p????µ????? ??a p??? apa?t?t???? efa?µ????.
4G??ssa p????aµµat?sµ?? µ????e?e??t??
?? µ????e?e??t?? ?e???? p????aµµat????ta? se
???sse? ?aµ???? ep?p?d??. ?e?e?ta?a ??? ?a?
pe??ss?te??? p????aµµat?st?? ep??????? ???sse?
?????te?? ep?p?d??. O? ???ssa ?aµ???? ep?p?d??
???µ??eta? µ?a ???ssa ? ?p??a ß??s?eta? p?? ???t?
st? ????? (???ssa µ??a???, assembly) O? ???ssa
?????? ep?p?d?? ???µ??eta? µ?a ???ssa ? ?p??a
e??a? a?st??? d?µ?µ??? ?a? ?p???e? s???e???µ????
compiler ? ?p???? µetat??pe? t? p????aµµa se
???ssa µ??a??? ??a t? s???e???µ??? µ????e?e??t?.
5G??ssa p????aµµat?sµ?? µ????e?e??t??
??e??e?t?µata ???ss?? ?aµ???? ep?p?d?? ?
p????aµµat?st?? ??e? t?? ap???t? ??e??? t??
s?µpe??f???? t?? µ????e?e??t? ?p??e? ?a
ep?t??e? µe ap???t? a???ße?a d??f?????
?????sµ??? ?e? apa?te?ta? ? dap??? ??a t??
a???? assembler ?a??? s?????? d?at??eta? d??e??
ap? t?? ?atas?e??st??a eta??e?a ?e???e?t?µata
???ss?? ?aµ???? ep?p?d?? ?pa?te?ta?
µe?a??te??? ??p?? ??a t?? e?µ???s? t?? s?µß??????
???ssa? t?? e??st?te µ????e?e??t? ?a
p?????µµata p?? d?µ????????ta? se s?µß?????
???ssa de? e??a? e?a?????sta ?a? ?
p????aµµat?st?? d?s???e?eta? ?a ??µ??e? t? ??????
p?? ??e? efa?µ?se? ?ta? ??e???eta? ?a ???e?
t??p?p???se?? e? t?? ?st???? ???a? d?s????te??
?a d???????? p????? p????aµµat?st?? st? ?d??
p????aµµa
6G??ssa p????aµµat?sµ?? µ????e?e??t??
??e??e?t?µata ???ss?? ?????? ep?p?d?? ???a?
e?????te?? ? a??pt??? µe????? ?a? s???et??
p????aµµ?t?? ?p????? ?a d???????? p?? e????a
p????? p????aµµat?st?? st? ?d??
p????aµµa ?e???e?t?µata ???ss?? ??????
ep?p?d?? Se efa?µ???? µe ???s?µ??? ?????sµ???
e??a? d?s????te?? ? s????af? ??d??a p??
a?tap?????eta? st??? ?????sµ??? a?t??? ?e?????
f???? ? dap??? ??a t?? a???? compiler de?
ap?te?e? aµe??t?? µ??e??? Se pa???te????
compilers ? ??d??a? µ??a??? p?? pa?a??ta? de?
?ta? ße?t?st?p???µ???? µe ap?t??esµa ?a
apa?te?ta? µ????e?e??t?? µe p??? pe??ss?te??
µ??µ?. ?? compilers p?? ?????f????? s?µe?a
d?a??t??? e?e???µ??a e??a?e?a ??a ße?t?st?p???s?
(optimization) t?? ??d??a ?a? ????? ?e?d?se? t??
eµp?st?s??? a??µa ?a? t?? p?? d?sp?st??
p????aµaµt?st??.
7?????e?e??t?? PIC
? Microchip d?a??te? p??? µe???? p??????a
µ????e?e??t??. 8-bit µ????e?e??t?? (???????e?e?
PIC10, PIC12, PIC16, PIC18) 16-bit
µ????e?e??t?? (???????e?e? PIC24, dsPIC) 32-bit
µ????e?e??t?? (???????e?e? PIC32) ? ep????? e???
µ????e?e??t? ??a µ?a efa?µ??? ???eta? µe t?? e???
d?ad??as?a. ?a???????ta? ?? p??d?a??af?? p??
p??pe? ?a p???e? ? µ????e?e??t?? ?a? ep????eta? ?
f????te??? p?? a?tap?????eta? st?? p??d?a??af??
a?t??. ? µ????e?e??t?? p?? ?a µe?et??e?
d?e??d??? sta p?a?s?a t?? µa??µat?? ?a e??a? ?
PIC16F887.
8PIC16F887
9PIC16F887
???a? µ????e?e??t?? µe d?a??? ded?µ???? 8-bit
??e? d?a??? d?e????se?? 9-bit ?e?t????e? µe
ta?a?t?t? ?????sµ?? µ???st?? s????t?ta? 20MHz
(es?te???? d?a??e? µe t? 4 ??a ?a pa???e? te????
5MHz ????? ????????) ??a??te? µ??µ?
p?????µµat?? 8? ???e?? ??a??te? RAM 368 bytes
??a??te? st??ßa 8 ??se?? ??a??te? ?EPROM
ded?µ???? 256 ??se?? ??a??te? 5 ???e? ?/?
(PORTA,PORTB,PORTC,PORTD,PORTE) ??a??te?
e?s?µat?µ??a d??f??a pe??fe?e?a?? ?????µata ?p??
Timers, ADC, MSSP (SPI/I2C), USART, CCP ??p. ?
epe?e??ast?? e??a? t?p?? RISC ?a? ?p?st????e?
s????? 35 e?t????. ???e e?t??? e?te?e?ta? se ??a
pa?µ? ???????? p??? t?? e?t???? d?a???d?s?? p??
e?te????ta? se d?? pa?µ???.
10???t?? µ??µ?? PIC16F887
11???t?? µ??µ?? PIC16F887
?e???aµß??e? 4 µp??? (?µ?de?) ?ata????t?? ?p??
t? ???e ??a ap? a?t? ???µ??eta? Bank. Bank0
h'00' h'7F' Bank1 h'80' h'FF' Bank2
h'100' h'17F' Bank3 h'180' h'1FF' ??p????
?ata????t?? t?? RAM ap?te???? t??? ?ata????t??
e?d???? ???s?? (Special Function Registers -
SFRs) ?a? ?? t?µ?? t??? ?a???????? t? s?µpe??f???
pe??fe?e?a??? t?? µ????e?e??t?. ?? ?p????p??
?ata????t?? ap?te???? t??? ?ata????t?? ?e?????
???s?? (General Purpose Registers GPRs) ?a?
µp????? ?a ???s?µ?p??????? ap? t?? p????aµµat?st?
??a t?? ap????e?s? ded?µ????. Bank0 GPRs h'20'
h'7F' Bank1 GPRs h'A0' h'EF' Bank2 GPRs
h'110' h'16F' Bank3 GPRs h'190' h'1EF'
12? ?ata????t?? STATUS
13S????? e?t???? PIC16F887 (Instruction Set)
14??t???? PIC16F887
1. clrf lt???µa ?ata????t?gt H e?t??? p?a?µat?p??e?
µ?de??sµ? t?? ?ata????t? p?? a??????e?. ?p??e??e?
t? Zero flag. p.?. clrf Register1 ?et? t??
e?t??es? ? Register1 ?a ??e? t?? t?µ? µ?d??. 2.
movlw lta???µ?t??? t?µ?gt ? e?t??? f??t??e? st??
s?ss??e?t? W t?? a???µ?t??? t?µ? p??
a??????e?. p.?. movlw h'64' ?et? t?? e?t??es? ?
W ?a ??e? t?? t?µ? 641610010
15??t???? PIC16F887
3. movwf lt???µa ?ata????t?gt H e?t??? ap????e?e?
ta pe??e??µe?a t?? s?ss??e?t? W st?? ?ata????t?
p?? a??????e? p.?. movwf Register1 ?et? t??
e?t??es? ? Register1 ?a ??e? ?p??a t?µ? e??e
p??????µ???? ? W. 4. movf lt???µa
?ata????t?gt,a af ? aw ? e?t??? d?aß??e? ta
pe??e??µe?a t?? ?ata????t? p?? a??????e? ?a? a?
af ta ap????e?e? st?? ea?t? t?? e?? a? aw ta
ap????e?e? st?? s?ss??e?t? W. ?p??e??e? t? Zero
flag. p.?. movf Register1,w ?et? t?? e?t??es? ?
W ?a ??e? ?p??a ded?µ??a e??e ? Register1
p??????µ????.
16??t???? PIC16F887
5. goto ltet???tagt H e?t??? p?a?µat?p??e? ??µa t??
PC st? d?e????s? µ??µ?? p?? a?apa??st??e? ?
et???ta. 6. addlw lta???µ?t??? t?µ?gt H e?t???
p??s??te? ta pe??e??µe?a t?? W µe t?? a???µ?t???
t?µ? p?? a??????e? ?a? ap????e?e? t? ?????sµa
st?? W. ?p??e??e? t? Carry flag ?a? t? Zero
flag. p.?. addlw d'25' ?et? t?? e?t??es? ? W ?a
??e? t? ?????sµa a??µesa st? 25 ?a? st?? t?µ? p??
e??e p??????µ????. W d'20' addlw d'25' W d'45'
17??t???? PIC16F887
7. addwf lt???µa ?ata????t?gt,a af ? aw ? e?t???
p??s??te? ta pe??e??µe?a t?? ?ata????t? p??
a??????e? µe ta pe??e??µe?a t?? W ?a? a? af
ap????e?e? t? ?????sµa st?? ?ata????t? e?? a? aw
t? ap????e?e? st? s?ss??e?t? W. ?p??e??e? t?
Carry ?a? t? Zero flag. p.?. addwf
Register1,w ?et? t?? e?t??es? ? W ?a ??e? t?
?????sµa a??µesa sta ded?µ??a p?? e??e
p??????µ???? ?a? sta ded?µ??a t?? Register1. W
d'25' W d'25' Register1
d'20' Register1 d'20' addwf
Register1,w addwf Register1,f W
d'45' W d'25' Register1
d'20' Register1 d'45'
18?a?ade??µata
1. ?a f??t?sete t?? t?µ? d'200' st?? W. movlw
d'200' 2. ?a ap????e?sete ta pe??e??µe?a t?? W
st?? ?ata????t? Reg1. movwf Reg1 3. ?a
p??s??sete t? d'50' sta pe??e??µe?a t??
?ata????t? W ?a? ?a ap????e?sete t? ap?t??esµa
st?? ?ata????t? Reg1. addlw d'50' movwf Reg1 4.
?a µ?de??sete ta pe??e??µe?a t? ?ata????t?
Reg1. clrf Reg1
19?a?ade??µata
5. ?a f??t?sete t? d'100' st?? ?ata????t? Reg1,
t? d'150' st?? W ?a? ?a p??s??sete Reg1 ?a? W. To
?????sµa ?a ap????e?te? st?? Reg1. movlw
d'100' movwf Reg1 movlw d'50' addwf Reg1,f 6. ?a
p?a?µat?p???sete t?? p???? t?? p??s?es??
20304050 ?a? ?a ap????e?sete t? te????
?????sµa st?? ?ata????t? Reg1. movlw d'20' addlw
d'30' addlw d'40' addlw d'50' movwf Reg1
20?a?ade??µata
7. ?a f??t?sete t? d'44' st?? ?ata????t? Reg1, t?
d'88' st?? Reg2, t? d'22' st?? Reg3 ?a? ?a
p??s??sete Reg1, Reg2 ?a? Reg3. To ?????sµa ?a
ap????e?te? st?? Reg1. movlw d'44' W
lt 44 movwf Reg1 Reg1 lt 44 movlw d'88' W
lt 88 movwf Reg2 Reg2 lt 88 movlw d'22' W
lt 22 movwf Reg3 Reg3 lt 22 movf Reg2,w W
lt 88 addwf Reg3,w W lt 110 addwf
Reg1,f Reg1 lt 154 S?µ. ???e p???? st??
a???µ?t??? ?????? µ???da ?p?st????eta? a??µesa
st? s?ss??e?t? W ?a? se ??p??? ?ata????t?
µ??µ??. ?e? ?p?st????eta? ape??e?a? p???? a??µesa
se pe??e??µe?a d?? ??se?? µ??µ??.
21?a??de??µa p?????µµat??
?a ???e? ??a p????aµµa p?? ????e? d?? ?ata????t??
Reg1, Reg2 se e?e??e?e? ??se?? µ??µ??, f??t??e?
st??? ?ata????t?? a?t??? t?? t?µ?? 100 ?a? 150
a?t?st???a ?a? p?a?µat?p??e? p??s?es? sta
pe??e??µe?? t???. ?? ap?t??esµa ap????e?eta? st??
W. include ltp16f887.incgt Reg1 equ h'20' Reg2 equ
h'21' org h'00' movlw d'100' movwf Reg1
movlw d'100' movwf Reg2 addwf Reg1,w LOOP
goto LOOP end
22?pe????s? ?d????? p??? t?? assembler
include ltp16f887.incgt ????s? a??e??? s?µß??????
???µ?t?? ?ata????t?? e?d???? ???s?? t??
µ????e?e??t?. Reg1 equ h'20' Reg2 equ h'21' ????s
? s?µß?????? ???µ?t?? ?ata????t?? ?e????? ???s??
st?? d?e????se?? t?? µ??µ?? RAM h'20' ?a?
h'21'. org h'00' ?d???a p??? t?? assembler ?a
t?p??et?se? t?? ??d??a p?? a??????e? ap? t? ??s?
µ??µ?? h'00' ?a? µet?. end ?d???a p??? t??
assembler ?t? te?e???e? t? a??e?? p??a??? ??d??a.