Title: Water
1???????S P?C16F887(INTERRUPTS)
?ta? s?µat?d?t??e? µ?a d?a??p? st?? PIC16F887, ?
??e???? t?? p?????µµat?? µetaf??eta? st? tµ?µa
??d??a p?? ß??s?eta? st? d?e????s? µ??µ?? h0004
? ?p??a ???µ??eta? ?a? d????sµa d?a??p??
(interrupt vector). ? ep?st??f? st? s?µe?? p??
ß??s??ta? ? µ????e?e??t?? p??? t? d?a??p?
p?a?µat?p??e?ta? µe t?? e?t??es? t?? e?t????
retfie (return from interrupt). ? PIC16F887
???s?µ?p??e? p??te ?ata????t?? ??a t? ???µ?s? t??
d?a??p??. ? ?ata????t?? INTCON e??a? ?pe??????
??a ta es?te???? interrupt t?? PIC. ??
?ata????t?? PIE1 ?a? PIE2 (Peripheral Interrupt
Enable) e??a? ?pe?????? ??a t?? e?e???p???s? ?
t?? ape?e???p???s? t?? d?a??p?? p?? a?t???ta? ta
pe??fe?e?a??. ?? ?ata????t?? PIR1 ?a? PIR2
(Peripheral Interrupt Request) pe??????? t??
s?µa?e? (flag bits) t?? d?a??p??. ?? d?a??p??
????? t? d??at?t?ta ?a ??p???? t? µ????e?e??t?
ap? t? ?e?t?????a ?aµ???? ?ata????s?? ?s????
(wake up from sleep). ?a?? e??a? ?a ap????e???ta?
ta pe??e??µe?a t?? ?ata????t?? STATUS ?a? W p???
t?? e?t??es? t?? ???t??a? d?a?e???s?? t??
d?a??p??.
2?ata????t?? INTCON ?ata????t?? INTCON
bit 7 GIE Bit e?e???p???s?? d?a??p?? 1 ??e???p???s? d?a??p?? 0 ?pe?e???p???s? d?a??p??
bit 6 PEIE Bit e?e???p???s?? d?a??p?? ap? ta pe??fe?e?a?? ?????µata t?? PIC16F887 1 ??e???p???s? d?a??p?? p?? a?t???ta? ta pe??fe?e?a?? 0 ?pe?e???p???s? d?a??p?? p?? a?t???ta? ta pe??fe?e?a??
bit 5 ??R0?? Bit e?e???p???s?? d?a??p?? ?at? t?? ?pe??e???s? t?? TMR0 1 ??e???p???s? d?a??p?? TMR0 0 ?pe?e???p???s? d?a??p?? TMR0
bit 4 INTE Bit e?e???p???s?? d?a??p?? ?at? t?? efa?µ??? a?e???µe??? (? ?ate???µe??? e?? ??e? ???µ?ste? ?at?????a) µet?p?? st?? a???d??t? RB0 1 ??e???p???s? d?a??p?? RB0 0 ?pe?e???p???s? d?a??p?? RB0
bit 3 RBIE Bit e?e???p???s?? d?a??p?? ?at? t? µet?ßas? t?? ??????? ?at?stas?? t?? tess???? a???de?t?? ?????? t???? t?? ???a PORTB 1 ??e???p???s? d?a??p?? 0 ?pe?e???p???s? d?a??p??
bit 2 TMR0IF S?µa?a s?µat?d?t?s?? d?a??p?? ?pe??e???s?? TMR0 1 ? TMR0 ??e? ?pe??e???se? (p??pe? ?a µ?de??ste? st? ????sµ???) 0 ? TMR0 de? ??e? ?pe??e???se?
bit 1 ???F S?µa?a s?µat?d?t?s?? d?a??p?? a?e???µe??? (? ?ate???µe??? e?? ??e? ???µ?ste? ?at?????a) µet?p?? st?? a???d??t? RB0 1 ??e???µe?? (? ?ate???µe??) µ?t?p? e?t?p?st??e st?? a???d??t? RB0 (p??pe? ?a µ?de??ste? st? ????sµ???) 0 ?e? e?t?p?st??e a?e???µe?? (? ?ate???µe??) µ?t?p? st?? a???d??t? RB0
bit 0 RBIF S?µa?a s?µat?d?t?s?? d?a??p?? ?at? t? µet?ßas? t?? ??????? ?at?stas?? t?? tess???? a???de?t?? ?????? t???? t?? ???a PORTB 1 ???????st?? ??a? ap? t??? a???d??te? RB7, RB6, RB5, RB4 ??e? a????e? ?????? ?at?stas?. ?? bit a?t? p??pe? ?a µ?de??ste? st? ????sµ??? af?? p??ta ???e? a?????s? t?? ???a? PORTB 0 ?a???a? ap? t??? a???d??te? RB7, RB6, RB5 ?a? RB4 de? ??e? a????e? ?????? ?at?stas?
3(No Transcript)
4?ata????t?? ANSEL (Bank3) ?ata????t?? ANSEL (Bank3)
bit 7 ANS7 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RE2/AN7 1 ? a???d??t?? RE2/AN7 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RE2/AN7 e??a? ??f?a?? e?s?d??/???d??
bit 6 ANS6 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RE1/AN6 1 ? a???d??t?? RE1/AN6 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RE1/AN6 e??a? ??f?a?? e?s?d??/???d??
bit 5 ANS5 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RE0/AN5 1 ? a???d??t?? RE0/AN5 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RE0/AN5 e??a? ??f?a?? e?s?d??/???d??
bit 4 ANS4 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RA5/AN4 1 ? a???d??t?? RA5/AN4 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RA5/AN4 e??a? ??f?a?? e?s?d??/???d??
bit 3 ANS3 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RA3/AN3 1 ? a???d??t?? RA3/AN3 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RA3/AN3 e??a? ??f?a?? e?s?d??/???d??
bit 2 ANS2 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RA2/AN2 1 ? a???d??t?? RA2/AN2 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RA2/AN2 e??a? ??f?a?? e?s?d??/???d??
bit 1 ANS1 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RA1/AN1 1 ? a???d??t?? RA1/AN1 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RA1/AN1 e??a? ??f?a?? e?s?d??/???d??
bit 0 ANS0 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? RA0/AN0 1 ? a???d??t?? RA0/AN0 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? RA0/AN0 e??a? ??f?a?? e?s?d??/???d??
5?ata????t?? ANSELH (Bank3) ?ata????t?? ANSELH (Bank3)
bit 7-6 ?e? e??a? ???p???µ??a
bit 5 ANS13 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?5/AN13 1 ? a???d??t?? R?5/AN13 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?5/AN13 e??a? ??f?a?? e?s?d??/???d??
bit 4 ANS12 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?0/AN12 1 ? a???d??t?? R?0/AN12 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?0/AN12 e??a? ??f?a?? e?s?d??/???d??
bit 3 ANS11 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?4/AN11 1 ? a???d??t?? R?4/AN11 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?4/AN11 e??a? ??f?a?? e?s?d??/???d??
bit 2 ANS10 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?1/AN10 1 ? a???d??t?? R?1/AN10 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?1/AN10 e??a? ??f?a?? e?s?d??/???d??
bit 1 ANS9 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?3/AN9 1 ? a???d??t?? R?3/AN9 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?3/AN9 e??a? ??f?a?? e?s?d??/???d??
bit 0 ANS8 Bits ep?????? a?a??????? ? ??f?a??? ?e?t?????a? st?? a???d??t? R?2/AN8 1 ? a???d??t?? R?2/AN8 e??a? a?a?????? e?s?d?? 0 ? a???d??t?? R?2/AN8 e??a? ??f?a?? e?s?d??/???d??
6RB0 Interrupt
O PIC16F887 ??e? t? d??at?t?ta ?a s?µ?tad?t?se?
d?a??p? se pe??pt?s? ?ate???µe??? (? a?e???µe???)
µet?p?? pa?µ?? st?? a??????t? RB0 (external
interrupt). ?? ?e???s??µe t? pa?a??t? ?????µa. ??
?p?te?e? ?t? ?????µe ?a a?????µe t? d??d? LED
?ta? pat?µe t? d?a??pt? S1. ?????? ? LED e??a?
sß?st?.
?? µ?t?p? p?? s?µat?d?te? t?? d?a??p? ?a?????eta?
ap? t? bit ????DG t?? ?ata????t? OPTION_REG. ?
d?a??p? e?e???p??e?ta? ?a???????ta? st? ??????
'1' t? bit ???? t?? ?ata????t? INTCON ?a? t?
?e???? bit GIE t?? INTCON.
7???G????? P?C16F887 ??a t? d?a??p? RB0
include ltp16f887.incgt org h'0000'
RESET vector goto START org h'0004'
Interrupt vector btfsc INTCON,INTF
??e???? a? ??e? s?µat?d?t??e? t? RB0 interrupt
call ISR_INTF ???t??a d?a?e???s??
d?a??p?? RB0 retfie START bsf STATUS,RP0
bsf STATUS,RP1 Bank3 bcf ANSELH,4
RB0 ???sµ?? ?? ??f?a?? e?s?d?? bcf
STATUS,RP1 Bank1 bcf TRISD,RD0
RD0 ??f?a?? ???d?? bsf TRISB,0
RB0 ??f?a?? e?s?d?? bcf OPTION_REG,INTEDG
???µ?s? d?a??p?? se ?ate???µe?? µ?t?p? bcf
STATUS,RP0 Bank0 bcf PORTD,1 bsf
INTCON,INTE ??e???p???s? RB0 d?a??p??
bsf INTCON,GIE ??e???p???s? s??????? t??
d?a??p?? LPM sleep ??s?d??
se Low Power Mode nop No
Operation goto LPM ISR_INTF bcf
INTCON,INTF bsf PORTD,RD0 return end
8????F??????? ????O???? PIC16F887
O PIC16F887 d?a??te? p?????a pe??fe?e?a???
?????µ?t?? µe ta ?p??a µp??e? ?a ep?te??se?
?d?a?te?a s???ete? e??as?e? ?a? ?a a?tap?????e?
ap?te?esµat??? ?a? se a??et? apa?t?t????
efa?µ???? pa?? t? ?e????? ?t? e??a? ?d?a?te?a
?aµ???? ??st???. ?a pe??fe?e?a?? p?? d?a??te? ?
PIC16F887 e??a? ???a ?????µata pa?a?????
???????? ?a??ste??se?? (Timers). ?etat??p?a
a?a??????? s?µat?? se ??f?a?? (Analog to Digital
Converter). ??a???????? s?????t?? (Analog
Comparators). ?????µa pa?a????? PWM
??µat?µ??f?? (Capture/Compare/PWM). ?????µa
s???????? se???a??? ep????????a? SPI ?a? I2C.
?????µa s????????/as???????? se???a???
ep????????a? (EUSART). ?????µa pa?a????? t?s??
a?af???? (Voltage Reference).
9ADC (Analog to Digital Converter)
10ADC (Analog to Digital Converter)
O PIC16F887 d?a??te? ADC µe 14 a?a?????? ?a????a
AN0 ??? ??13 ta ?p??a p???p?????ta? se d??f?????
a???d??te? t?? µ????e?e??t?. ??f??p??e?ta? ? t?s?
ap? ??a ?a???? ???e f??? p?? ? ADC ???e? µ?a
µetat??p?. ?? µ??t??? t?? a?a??????? ?a?a????
pa???s???eta? st? pa?a??t? s??µa. ??s?
p????aµµat?sµ?? ??e??e? ? d?a??pt?? SS ?a? ?
p????t?? CHOLD f??t??eta? µe t?? t?s? p???
µetat??p?. St? s????e?a a????e? ? d?a??pt?? SS
?a? ? ADC p?a?µat?p??e? t? µetat??p? st?? t?s?
t?? p????t?. S?µ. Rs lt 10K
11ADC (Analog to Digital Converter)
G?a t? d?a?e???s? t?? ADC ?pe?????? e??a? ??
pa?a??t? ?ata????t?? ADCON0 ?ata????t??
d?a?e???s?? ?a? e?????? 0 (Bank0) ADCON1
?ata????t?? d?a?e???s?? ?a? e?????? 1
(Bank1) ADRESH ?yte ?????? t???? t??
ap?te??sµat?? (Bank0) ADRESL ?yte ?aµ???? t????
t?? ap?te??sµat?? (Bank1) ??SEL ?ata????t??
d?a?e???s?? a?a???????/??f?a??? e?s?d??
(Bank3) ??SEL? ?ata????t?? d?a?e???s??
a?a???????/??f?a??? e?s?d?? (Bank3)
12?ata????t?? ADCON0 (Bank0) ?ata????t?? ADCON0 (Bank0)
bit 7-6 ADCS1ADCS0 Bits ep?????? ???????? µetat??p?a A/D 00 FOSC/2 01 FOSC/8 10 FOSC/32 11 FRC (t? ????? ?aµß??eta? ap? es?te???? RC ta?a?t?t? µ???st?? s????t?ta? 500KHz)
bit 5-2 CHS2CHS0 Bits ep?????? a?a??????? ?a?a???? 0000 ?a???? 0 (??0/RA0) 0001 ?a???? 1 (??1/RA1) 0010 ?a???? 2 (??2/RA2) 0011 ?a???? 3 (??3/RA3) 0100 ?a???? 4 (??4/RA5) 0101 ?a???? 5 (??5/RE0) 0110 ?a???? 6 (??6/RE1) 0111 ?a???? 7 (??7/RE2) 1000 ?a???? 8 (??8/R?2) 1001 ?a???? 9 (??9/R?3) 1010 ?a???? 10 (??10/R?1) 1011 ?a???? 11 (??11/R?4) 1100 ?a???? 12 (??12/R?0) 1101 ?a???? 13 (??13/R?5) 1110 ??s? a?af???? s?????t? 1111 ??s? a?af???? 0.6V
bit 1 GO/DONE Bit ?at?stas?? A/D µetat??p?? 1 A/D µetat??p? se e?????? (T?t??ta? t? bit a?t? st? ?????? 1 ?e???? ? d?ad??as?a µetat??p?? ?a? ?ta? ?????????e? t?te µ?de???eta? a?t?µata) 0 ?e? ?p???e? µetat??p? A/D se e?????? ? ? µetat??p? ??e? ?????????e?
bit 0 ADON Bit e?e???p???s?? µetat??p?a A/D 1 ? µetat??p?a? A/D e??a? e?e???p???µ???? 0 ? µetat??p?a? A/D e??a? ape?e???p???µ????
13?ata????t?? ADCON1 (Bank1) ?ata????t?? ADCON1 (Bank1)
bit 7 ADFM Bit ep?????? µ??f?? ap?te??sµat?? 1 ?? 10-bit ap?t??esµa t?? µetat??p?? ?a e??a? st????sµ??? de??? st? ?e???? ?ata????t?? ADRESHADRESL. ?a p?? s?µa?t??? bits t?? ADRESH d?aß????ta? ?? 0 0 ?? 10-bit ap?t??esµa t?? µetat??p?? ?a e??a? st????sµ??? a??ste?? st? ?e???? ?ata????t?? ADRESHADRESL. ?a ????te?? s?µa?t??? bits t?? ADRESL d?aß????ta? ?? 0
bit 6 ?e? e??a? ???p???µ???
bit 5 VCFG1 Bit ep?????? ?aµ???? t?s?? a?af???? 1 ? ?aµ??? t?s? a?af???? ?aµß??eta? ap? t?? a???d??t? VREF- 0 ? ?aµ??? t?s? a?af???? ?aµß??eta? ap? t? ?e??s? VSS
bit 4 VCFG1 Bit ep?????? ?????? t?s?? a?af???? 1 ? ????? t?s? a?af???? ?aµß??eta? ap? t?? a???d??t? VREF 0 ? ????? t?s? a?af???? ?aµß??eta? ap? t?? t??f?d?s?a VDD
bit 3-0 ?e? e??a? ???p???µ??a
? ?????? µetat??p?? ??a ???e bit ???µ??eta? ?AD.
? µetat??p?a? t?? µ????e?e??t? apa?te? ??a t?
s?st? ?e?t?????a t?? ????? t? ?p??? ?a?????e?
t?µ? t?? ?????? ?AD µe?a??te?? t?? 1.6µsec. ?et?
t?? ?a????sµ? t?? a?a??????? ?a?a???? p?? ?a
???s?µ?p????e? ??a µ?a µetat??p? ?a p??pe? ?a
pa????e? ??a ??????? d??st?µa (acquisition time)
p??? ?e????se? ? µetat??p?. ?? ??????? d??st?µa
apa?te?ta? ?ste ?a ap??t?se? t?? efa?µ???µe??
t?s? p??? µetat??p? t? es?te???? ?????µa
de??µat?????a? ?a? s?????t?s?? t?? µ????e?e??t?.
??a t?p??? t?µ? t?? d?ast?µat?? a?t?? ??a t??
PIC16F887 e??a? 4.67µsec.
14ADC (Analog to Digital Converter)
??a??t??? ta ß?µata p?? p??pe? ?a a???????????
??a t? ???µ?s? ?a? t? ???s?µ?p???s? t?? A/D
Converter t?? PIC16F887 e??a? ???µ?s? t??
?a?a???? p?? ?a ???s?µ?p??????? ?a???????ta? st?
?????? 1 ta a?t?st???a bit t?? ?ata????t??
ANSEL ?a? ANSELH ?a??? ep?s?? ?a? ta a?t?st???a
bit t?? ?ata????t?? TRISA, TRISB ?a? TRISE.
?p????? ???????? ??a t?? A/D ???µ????ta?
?at?????a ta bit ADCS1, ADCS0 t?? ?ata????t?
ADCON0 ?a????sµ?? t?? t?se?? a?af????
???µ????ta? ?at?????a ta bit VCFG1 ?a? VCFG0 t??
?ata????t? ADCON1 ?a????sµ?? t?? ?a?a???? t?
?p??? ?a efa?µ?ste? st? es?te???? ?????µa
de??µat?????a? ?a? s?????t?s?? t?? µ????e?e??t?
???µ????ta? ?at?????a ta bit CHS3, CHS2, CHS1 ?a?
CHS0 t?? ?ata????t? ADCON0 ???µ?s? t?? bit ADFM
t?? ?ata????t? ADCON1 ??a de??? ? a??ste??
st????s? t?? ap?te??sµat?? t?? µetat??p?? st???
?ata????t?? ADRESHADRESL ??e???p???s? t??
?????µat?? t?? µetat??p?a ??t??ta? st? ?????? 1
t? bit ADON t?? ?ata????t? ADCON0 ??e???p???s?
t?? d?a??p?? e?? e??a? ep???µ?t? ??aµ??? µ????
?a pa????e? t? ??????? d??st?µa acquisition
time ??????s? t?? µetat??p?? ??t??ta? st?
?????? 1 t? bit GO/DONE t?? ?ata????t? ADCON0
??aµ??? µ???? ?a ?????????e? ? µetat??p?
e?et????ta? p?te ?a µ?de??ste? t? bit GO/DONE
??????s? t?? ?ata????t?? ADRESHADRESL ??a
epe?e??as?a t?? ap?te??sµat??
15ADC (Analog to Digital Converter)
? PIC16F887 µp??e? ?a ??f??p???se? t?se?? se
pe?????? ap? 0V ??? 5V. ?? ?? t?se?? p?? ?????µe
?a d?aß?s??µe a?????? se d?af??et??? e???? t?µ??
t?te e??a? apa?a?t?t? ? p??sa?µ??? t??? sta
ap?de?t? ep?peda µe t? ???s? te?est????
e??s??t??. ?? ap?t??esµa µ?a? 10-bit µetat??p??
e??a? ??a? a???µ?? ap? t? 0 ??? t? 1023 (210-1).
???s?µ?p????ta? ?? t?se?? a?af???? 0V ?a? 5V ?
ADC ?a µp??e? ?a d?a????e? d?af??et???? t?se??
?at? 4.8mV (5V/1024). St? s??t??pt??? p?e????f?a
t?? efa?µ???? µe ADC a?t? ?a?a?t???st??? ?a??pte?
t??? s?ed?ast??. ????ste ???t? se a?t? t?? t?µ?
?a???????ta? ?a? ta ep?peda t?? ??e?t???????
????ß??. ? s??s? p?? d??e? t? ap?t??esµa t??
µetat??p?? e??a? ? e??? ADRESHADRESL
1023?Vin/5, ?p?? AVin e??a? ? a?a?????? t?s? p??
efa?µ??eta? st?? ADC t?? µ????e?e??t?. ?? a???a??
µ???? t?? ap?te??sµat?? ap????e?eta? st???
?ata????t?? ADRESH ?a? ADRESL t?? µ????e?e??t?.
G?a t?? p????aµµat?st? ?µ?? ? ????st?? ???? e??a?
? a?a?????? t?s? p?? efa?µ??eta? ?a? a?t? ?a
p??pe? ?a ?p?????se?. ?ts? se µ?a µetat??p? ?
p????aµµat?st?? ?a?e?ta? s?????? ?a
p?a?µat?p???se? t?? p???e?? t?? pa?a??t?
s??s?? AVin 5 (ADRESHADRESL) / 1023 Se
a??et?? pe??pt?se?? ? d?a??es? µe t? 1023
a?t??a??stata? p??se???st??? µe t? 1024 ? ?p??a
µp??e? e????a ?a p?a?µat?p????e? µe µetat?p?se??
t?? d?a???t? p??? ta de???.
16???????G?? ???S?S ADC
?a a?apt???e? µ?a efa?µ??? ? ?p??a ???s?µ?p??e?
t?? ADC t?? µ????e?e??t?, ??f??p??e? µ?a
a?a?????? t?s? p?? efa?µ??eta? st?? a???d??t? RA0
(??0) ?a? e?? ? t?s? a?t? e??a? p??? ap? 2.5V
?d??e? st? ?????? 1 t?? a???d??t? RD1 t??
PIC16F887 e?? a? e??a? ??t? ap? 2.5V t?? ?d??e?
st? ?????? 0. ?? ?????? d????aµµa t??
p?????µµat?? pa???s???eta? de???.
17?O????S ???????G????S ???S?S ADC
include ltp16f887.incgt DelayReg equ h'20' org h'0000' nop bcf STATUS,RP1 bcf STATUS,RP0 Bank0 movlw b'10000001' W lth'81' movwf ADCON0 ADCON0 lt h'81' bsf STATUS,RP0 Bank1 movlw b'10000000' W lt h'80' movwf ADCON1 ADCON1 lt h'80' bcf TRISD,1 RD1 lt- ???d?? bcf STATUS,RP0 Bank0 bcf PORTD,1 RD1 lt '0' LOOP movlw d'20' W lt d'20' movwf DelayReg DelayReg lt d'20' ACQ_DELAY decfsz DelayReg,f Acquisition Delay 12usecgt4,67usec goto ACQ_DELAY bsf ADCON0,GO ??a??? µetat??p?? ADC_COMPLETED btfsc ADCON0,GO ??e???? ????????s?? µetat??p?? goto ADC_COMPLETED St? s?µe?? a?t? ?? ?ata????t?? ADRESHADRESL ?a p??pe? ?a ????? t? ap?t??esµa t?? µetat??p?? a?a??????? s?µat?? se ??f?a?? movlw d'2' W lt d'2' subwf ADRESH,w W lt ADRESH - W btfss STATUS,C ?a???aµ?? a? C1 bcf PORTD,1 RD1 lt '0' btfsc STATUS,C ?a???aµ?? a? C0 bsf PORTD,1 RD1 lt '1' goto LOOP end
18KY??O?? ???????G????S
19??????????? ??G?S??
?a ep?????e? ?p??et??? ?a? a????fa??? p??ß??µa t?
?p??? ?a ep????e? µe t? ß???e?a t?? µ????e?e??t?
PIC16F887. ?a d?at?p??e? µe ?ept?µ??e?a ?a? ?a
t???st??? ta ?ept? s?µe?a t?? p??ß??µat?? ?a???
?a? t? p?? p??pe? ?a est??se? ?a?e?? ??a t??
ep???s? t??. ?a pa???s?aste? ? ??s? t??
p??ß??µat??. ????????s? Ta a????????e? ??? µ???
? ??s? a??? ?a? t? ?at? p?s? t? p??ß??µa p?? ?a
pa???s?aste? pa???s???e? ep?st?µ????? ? p?a?t???
s?µas?a. ?? ??a t? p??ß??µa p?? ?a ep?????e?
???e? ?a? ?atas?e?? t?te ? e??as?a µp??e? ?a
a????????e? µ???? 3 µ???de? t? ???sta ?a? µp?????
?a s?µµet????? st? ?d?? ??µa µ???? d?? t? p???
sp??dast??. ?? ??a t? p??ß??µa p?? ?a ep?????e?
a?apt???e? µ??? ??d??a? ?a? ???e? simulation st?
MPLAB t?te ? e??as?a ?a e??a? at?µ??? ?a? µp??e?
?a a????????e? µ???? 2 µ???de? t? ???sta. ?
ßa?µ?????a ?a a????ste? ?? bonus a?e?a?t?t?? t??
te????? ßa?µ?????a? st?? ??apt?? e?et?se??. O?
?µe??µ???a pa??d?s?? ?a? pa???s?as?? t?? e??as?a?
e??a? ? ?et??t? 16 ?a???a???? 2013.