www.elektronik.si Seznam forumov www.elektronik.si
Forum o elektrotehniki in računalništvu
 
 PomočPomoč  IščiIšči  Seznam članovSeznam članov  SkupineSkupine  StatisticsStatistika  AlbumAlbum  DatotekeFilemanager DokumentacijaDocDB LinksPovezave   Registriraj seRegistriraj se 
  PravilaPravila  LinksBolha  PriponkePriponke  KoledarKoledar  ZapiskiZapiski Tvoj profilTvoj profil Prijava za pregled zasebnih sporočilPrijava za pregled zasebnih sporočil PrijavaPrijava 

Pic16f870 uporaba PORTA za prižiganje led diod
Pojdi na stran 1, 2  Naslednja
 
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> Microchip PIC
Poglej prejšnjo temo :: Poglej naslednjo temo  
Avtor Sporočilo
compaq
Član
Član



Pridružen-a: Tor 10 Mar 2009 12:53
Prispevkov: 100
Aktiv.: 0.50
Kraj: Maribor

PrispevekObjavljeno: Tor Maj 08, 2012 3:40 pm    Naslov sporočila:  Pic16f870 uporaba PORTA za prižiganje led diod Odgovori s citatom

Torej kot že naslov pove se mi je zadeva ustavila pri portuA...
Ker imam ostala porta zasedena, sem se odločil, da 3 led diode priključim na A0, A1, A2 na pinu A5 pa je one wire senzor...

Te tri diode bi bile samo za indikacijo (prižiganje, etc...)
Pomoč bi rabil, pri definicija pina A0..A3. Kako naj določim da bo pin digitalen in izhod...???

programska oprema pa je MikroC pro for PIC
lp

_________________
Za vsakega drifterja raste robnik!!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
primozsu
Član
Član



Pridružen-a: Sre 16 Feb 2005 9:11
Prispevkov: 412
Aktiv.: 1.74
Kraj: MB - Šentjur

PrispevekObjavljeno: Tor Maj 08, 2012 4:22 pm    Naslov sporočila:   Odgovori s citatom

Tu si poglej.

Drugače pa tole:

Koda:

void main() {

    ANSEL = 0;                      // All I/O pins are configured as digital
    ANSELH = 0;
    PORTA = 0;                      // All port A pins are set to 0
    TRISA = 0;                      // Port A pins are configured as outputs
   
    while(1)
    {
            PORTA = 0b00000111;
            Delay_ms(500);
            PORTA = 0b00000000;
            Delay_ms(500);
    }
}

Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
compaq
Član
Član



Pridružen-a: Tor 10 Mar 2009 12:53
Prispevkov: 100
Aktiv.: 0.50
Kraj: Maribor

PrispevekObjavljeno: Tor Maj 08, 2012 4:39 pm    Naslov sporočila:   Odgovori s citatom

Že že ampak ta tvoj primer ne velja za moj PIC16f870 ampak za f877
imajo razločno anselh ipd...

moj ima ADCON1 = 0x06; // Configure all pins as digital I/O

_________________
Za vsakega drifterja raste robnik!!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Highlag
Član
Član



Pridružen-a: Pet 23 Jan 2004 20:42
Prispevkov: 4034
Aktiv.: 17.03
Kraj: Črnuče

PrispevekObjavljeno: Tor Maj 08, 2012 4:49 pm    Naslov sporočila:   Odgovori s citatom

Sam si pomagam s pripeto datoteko.
Sicer je mišljena za Basic, vendar so registri tisto kar je pomembno.
Poišči svoj procesor pa boš videl kateri registri so tisi, ki jih rabiš vključit v konfiguracijo. Pogledaš še datasheet, za posamezen register pa je.
Koda:

module all_digital

implements

sub procedure AllDigital()
#IFDEF P16 THEN

#IFDEF P12C671 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P12C672 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P12CE673 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P12CE674 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P12F609 THEN
  CMCON0.7 = 0                      ' turn off comparators
  ANSEL = ANSEL and %11110100       ' turn off analog inputs
#ENDIF

#IFDEF P12F615 THEN
  CMCON0.7 = 0                      ' turn off comparators
  ANSEL = ANSEL and %11110000       ' turn off analog inputs
#ENDIF

#IFDEF P12F629 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P12F635 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
#ENDIF

#IFDEF P12F675 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ANSEL = ANSEL and %11110000       ' turn off analog inputs
#ENDIF

#IFDEF P12F683 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = ANSEL and %11110000       ' turn off analog inputs
#ENDIF

#IFDEF P12HV609 THEN
  CMCON0.7 = 0                      ' turn off comparators
  ANSEL = ANSEL and %11110100       ' turn off analog inputs
#ENDIF

#IFDEF P12HV615 THEN
  CMCON0.7 = 0                      ' turn off comparators
  ANSEL = ANSEL and %11110000       ' turn off analog inputs
#ENDIF

#IFDEF P16C432 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C433 THEN
  ADCON1 = ADCON1 or 0x07
#ENDIF

#IFDEF P16C620 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C620A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C621 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C621A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C622 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C622A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C642 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C662 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16C71 THEN
  ADCON1 = ADCON1 or 0x03           ' turn off analog inputs
#ENDIF

#IFDEF P16C710 THEN
  ADCON1 = ADCON1 or 0x03           ' turn off analog inputs
#ENDIF

#IFDEF P16C711 THEN
  ADCON1 = ADCON1 or 0x03           ' turn off analog inputs
#ENDIF

#IFDEF P16C712 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C715 THEN
  ADCON1 = ADCON1 or 0x03           ' turn off analog inputs
#ENDIF

#IFDEF P16C716 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C717 THEN
  ANSEL = ANSEL and %11000000       ' turn off analog inputs
#ENDIF

#IFDEF P16C72 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C72A THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C73 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C73A THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C73B THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C74 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C745 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C74A THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C74B THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C76 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C765 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C77 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C770 THEN
  ANSEL = ANSEL and %11000000       ' turn off analog inputs
#ENDIF

#IFDEF P16C771 THEN
  ANSEL = ANSEL and %11000000       ' turn off analog inputs
#ENDIF

#IFDEF P16C773 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16C774 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16C781 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16C782 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16C924 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16C925 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16C926 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16CE623 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16CE624 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16CE625 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16CR72 THEN
  ADCON1 = ADCON1 or 0x07
#ENDIF

#IFDEF P16F610 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %00001100       ' turn off analog inputs
#ENDIF

#IFDEF P16F616 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F627 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F627A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F628 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F628A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F630 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F631 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F636 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
#ENDIF

#IFDEF P16F639 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
#ENDIF

#IFDEF P16F648A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F676 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F677 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F684 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F685 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F687 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F688 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F689 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F690 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F716 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F72 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F73 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F737 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16F74 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F747 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16F76 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F767 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16F77 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
#ENDIF

#IFDEF P16F777 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P16F785 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL0 = 0                        ' turn off analog inputs
  ANSEL1 = ANSEL1 and %11110000     ' turn off analog inputs
#ENDIF

#IFDEF P16F818 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F819 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F87 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P16F870 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F871 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F872 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F873 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F873A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F874 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F874A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F876 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F876A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F877 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F877A THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P16F88 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F882 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11000000     ' turn off analog inputs
#ENDIF

#IFDEF P16F883 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %1110000        ' turn off analog inputs
  ANSELH = ANSELH and %11000000     ' turn off analog inputs
#ENDIF

#IFDEF P16F884 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11000000     ' turn off analog inputs
#ENDIF

#IFDEF P16F886 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %1110000        ' turn off analog inputs
  ANSELH = ANSELH and %11000000     ' turn off analog inputs
#ENDIF

#IFDEF P16F887 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11000000     ' turn off analog inputs
#ENDIF

#IFDEF P16F913 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = ANSEL and %11100000       ' turn off analog inputs
#ENDIF

#IFDEF P16F914 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F916 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = ANSEL and %11100000       ' turn off analog inputs
#ENDIF

#IFDEF P16F917 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16F946 THEN
  CMCON0 = CMCON0 or 0x07           ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16HV610 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %00001100       ' turn off analog inputs
#ENDIF

#IFDEF P16HV616 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
#ENDIF

#IFDEF P16HV785 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL0 = 0                        ' turn off analog inputs
  ANSEL1 = ANSEL1 and %11110000     ' turn off analog inputs
#ENDIF

#ELSE

#IFDEF P18F1220 THEN
  ADCON1 = ADCON1 or %01111111      ' turn off analog inputs
#ENDIF

#IFDEF P18F1230 THEN
  ADCON1 = ADCON1 and %10000000     ' turn off analog inputs
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P18F1320 THEN
  ADCON1 = ADCON1 or %01111111      ' turn off analog inputs
#ENDIF

#IFDEF P18F1330 THEN
  ADCON1 = ADCON1 and %10000000     ' turn off analog inputs
  CMCON = CMCON or 0x07             ' turn off comparators
#ENDIF

#IFDEF P18F2220 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2221 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2320 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2321 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2331 THEN
  ANSEL0 = ANSEL0 and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F2410 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F242 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F2420 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2423 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2431 THEN
  ANSEL0 = ANSEL0 and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F2439 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2450 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2455 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2458 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F248 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F2480 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F24J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F24K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %1110000        ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F2510 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2515 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F252 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F2520 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2523 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2525 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2539 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2550 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2553 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F258 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F2580 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2585 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F25J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F25K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %1110000        ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F2610 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2620 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2680 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2682 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F2685 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F26K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = ANSEL and %1110000        ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F4220 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4221 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4320 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4321 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4331 THEN
  ANSEL0 = 0                        ' turn off analog inputs
  ANSEL1.0 = 0                      ' turn off analog inputs
#ENDIF

#IFDEF P18F4410 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F442 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F4420 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4423 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4431 THEN
  ANSEL0 = 0                        ' turn off analog inputs
  ANSEL1.0 = 0                      ' turn off analog inputs
#ENDIF

#IFDEF P18F4439 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4450 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4455 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4458 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F448 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F4480 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F44J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F44K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F4510 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4515 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F452 THEN
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F4520 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4523 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4525 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4539 THEN
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4550 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4553 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F458 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
  ADCON1.3 = 0
#ENDIF

#IFDEF P18F4580 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4585 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F45J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F45K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F4610 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4620 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4680 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4682 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F4685 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F46K20 THEN
  CM1CON0.7 = 0                     ' turn off comparators
  CM2CON0.7 = 0                     ' turn off comparators
  ANSEL = 0                         ' turn off analog inputs
  ANSELH = ANSELH and %11100000     ' turn off analog inputs
#ENDIF

#IFDEF P18F6310 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6390 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6393 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F63J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F63J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6410 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6490 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6493 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F64J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F64J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6520 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6525 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6527 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6585 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F65J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F65J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F65J15 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F65J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001100      ' turn off analog inputs
#ENDIF

#IFDEF P18F65J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6620 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6621 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6622 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6627 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6628 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6680 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F66J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F66J11 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001111      ' turn off analog inputs
#ENDIF

#IFDEF P18F66J15 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F66J16 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001111      ' turn off analog inputs
#ENDIF

#IFDEF P18F66J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001100      ' turn off analog inputs
#ENDIF

#IFDEF P18F66J55 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001100      ' turn off analog inputs
#ENDIF

#IFDEF P18F66J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F66J65 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6720 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6722 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F6723 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F67J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F67J11 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001111      ' turn off analog inputs
#ENDIF

#IFDEF P18F67J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %00001100      ' turn off analog inputs
#ENDIF

#IFDEF P18F67J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8310 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8390 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8393 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F83J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F83J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8410 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8490 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8493 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F84J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F84J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8520 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8525 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8527 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8585 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F85J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F85J11 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F85J15 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F85J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %11111100      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F85J90 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8620 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8621 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8622 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8627 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8628 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8680 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F86J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F86J11 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = 255                      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F86J15 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F86J16 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = 255                      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F86J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %11111100      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F86J55 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %11111100      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F86J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F86J65 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8720 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8722 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8722b THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F8723 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F87J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F87J11 THEN
  ANCON0 = ANCON0 or %11011111      ' turn off analog inputs
  ANCON1 = 255
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F87J50 THEN
  ANCON0 = ANCON0 or %10011111      ' turn off analog inputs
  ANCON1 = ANCON1 or %11111100      ' turn off analog inputs
  MEMCON.7 = 1                      ' disable external memory bus
#ENDIF

#IFDEF P18F87J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F96J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F96J65 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18F97J60 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  MEMCON.7 = 1                      ' disable external memory bus
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18LF24J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18LF25J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18LF44J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#IFDEF P18LF45J10 THEN
  CMCON = CMCON or 0x07             ' turn off comparators
  ADCON1 = ADCON1 or 0x0F           ' turn off analog inputs
#ENDIF

#ENDIF

end sub

end.
[/list]
_________________
If at first you don't succeed, destroy all evidence that you tried.
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Obišči avtorjevo spletno stran
red_mamba
Član
Član



Pridružen-a: Ned 20 Feb 2005 17:56
Prispevkov: 1486
Aktiv.: 6.27
Kraj: Yogyakarta

PrispevekObjavljeno: Tor Maj 08, 2012 5:19 pm    Naslov sporočila:   Odgovori s citatom

compaq je napisal/a:
Že že ampak ta tvoj primer ne velja za moj PIC16f870 ampak za f877
imajo razločno anselh ipd...

moj ima ADCON1 = 0x06; // Configure all pins as digital I/O


Pogledas v datasheet za microcontroller kaj pravijo pod opisi za pine ADCON1 registra Wink

_________________
Bad things happen to good people all the time for no reason!
Blog
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Obišči avtorjevo spletno stran
compaq
Član
Član



Pridružen-a: Tor 10 Mar 2009 12:53
Prispevkov: 100
Aktiv.: 0.50
Kraj: Maribor

PrispevekObjavljeno: Tor Maj 08, 2012 5:30 pm    Naslov sporočila:   Odgovori s citatom

sem pogruntal....

ampak imam občutek da mi ne dela pravilno....
Koda:

int main()
{
PORTA = 0;
ADCON1 = 0x06;
TRISA = 0x38;
PORTA.B0 = 1;
PORTA.B1 = 1;
PORTA.B2 = 1;

pač ko prižgem, mi svetita samo a1 in pa a2 lediki.... sem poizkušal da bi jih prižgal pa za en čas ugasnil pa je rezultat enak....ne ugasnejo :S

_________________
Za vsakega drifterja raste robnik!!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
red_mamba
Član
Član



Pridružen-a: Ned 20 Feb 2005 17:56
Prispevkov: 1486
Aktiv.: 6.27
Kraj: Yogyakarta

PrispevekObjavljeno: Tor Maj 08, 2012 7:52 pm    Naslov sporočila:   Odgovori s citatom

Koda:

while(1)
    {
            PORTA = 0b00000111;
            Delay_ms(500);
            PORTA = 0b00000000;
            Delay_ms(500);
    }


Tole ti dela ce das v main takoj za init porta?
Da ne povozis kje inicializacije porta.
Recimo z 1Wire rutinami

_________________
Bad things happen to good people all the time for no reason!
Blog
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Obišči avtorjevo spletno stran
wicket
Član
Član



Pridružen-a: Sob 28 Maj 2011 15:19
Prispevkov: 29
Aktiv.: 0.17
Kraj: Ljubljana

PrispevekObjavljeno: Pet Jun 01, 2012 7:50 pm    Naslov sporočila:   Odgovori s citatom

Če si lahko sposodim kar tole temo...

Gre za PIC16F628A, na PORTA imam 2 vhoda (2,3) in 2 izhoda (0,1) z ledicami. Če sta vhoda različna gori 1. ledica, če sta enaka gori 2. Nekakšen xor torej...

Bi mi kdo lahko predlagal, kako bi okrnil spodnjo kodo? Probal sem tako, kot je zakomentirano, ampak zadeva ne dela.



Koda:

void main() {
     TRISA = 0b00001100;
     CMCON = 0b111;     // comparators off
     
     while (1) {
           
           if ((PORTA.B2 == 0)&&(PORTA.B3 == 0)) {
              PORTA.B0 = 0;
              PORTA.B1 = 1;
           }
           else if ((PORTA.B2 == 1)&&(PORTA.B3 == 1)) {
              PORTA.B0 = 0;
              PORTA.B1 = 1;
           }
           else if ((PORTA.B2 == 1)&&(PORTA.B3 == 0)) {
              PORTA.B0 = 1;
              PORTA.B1 = 0;
           }
           else if ((PORTA.B2 == 0)&&(PORTA.B3 == 1)) {
              PORTA.B0 = 1;
              PORTA.B1 = 0;
           }
         

           /*if (PORTA == 0b0000) PORTA = 0b10;
           else if (PORTA == 0b1100) PORTA = 0b10;
           else if (PORTA == 0b1000) PORTA = 0b01;
           else if (PORTA == 0b0100) PORTA = 0b01;*/

     }
}
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Alex17
Član
Član



Pridružen-a: Ned 28 Feb 2010 21:46
Prispevkov: 476
Aktiv.: 2.56
Kraj: Ljutomer

PrispevekObjavljeno: Pet Jun 01, 2012 8:19 pm    Naslov sporočila:   Odgovori s citatom

Koda:
if(PORTA.B2 == PORTA.B3 ){
  PORTA.B0 = 1;
  PORTA.B1 = 0;
}
else{
  PORTA.B0 = 0;
  PORTA.B1 = 1;
}


Oz. kot si sam povedal
Koda:
PORTA.B0 = PORTA.B2^PORTA.B3;
PORTA.B1 = !PORTA.B0;


Tistega zakometnrianega dela kode ap ne moreš uporabiti zato, ker ne veš katero LED imaš vključeno (ker si mimogrede v preverjanju zajel še pina 0 in 1)
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
wicket
Član
Član



Pridružen-a: Sob 28 Maj 2011 15:19
Prispevkov: 29
Aktiv.: 0.17
Kraj: Ljubljana

PrispevekObjavljeno: Pet Jun 01, 2012 8:25 pm    Naslov sporočila:   Odgovori s citatom

Hmm ja, mogoče sem malo nerodno vprašal. Wink

Za konkreten primer je tole ok, predvsem me pa zanima če bi imel recimo 4 vhode, torej 16 možnih kombinacij. Kako bi najlažje napisal če je na vhodu kombinacija xxxx, prižgi izhode a,b,c...

Ča naprimer preverjam stanje bitov v binarni obliki, a obstaja način, da je vseeno če je bit 1 ali 0. Nekaj v smislu 0b0010xx01 ? Se pravi da ni važno kaj je na mestu x?
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Alex17
Član
Član



Pridružen-a: Ned 28 Feb 2010 21:46
Prispevkov: 476
Aktiv.: 2.56
Kraj: Ljutomer

PrispevekObjavljeno: Pet Jun 01, 2012 8:41 pm    Naslov sporočila:   Odgovori s citatom

Maskiranje bitov:
Koda:
if(PORTA & 0x11110011 = 0x00110011)

Tam kjer and-aš z 1 dobiš vrednost tako kot je na pinu, tam kjer imaš 0 pa dobiš vrnjeno 0. V zgornjem primeru se upoštevajo samo biti 7-4 in 0-1.
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
wicket
Član
Član



Pridružen-a: Sob 28 Maj 2011 15:19
Prispevkov: 29
Aktiv.: 0.17
Kraj: Ljubljana

PrispevekObjavljeno: Sob Jun 02, 2012 1:47 pm    Naslov sporočila:   Odgovori s citatom

Štima, hvala!
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
wicket
Član
Član



Pridružen-a: Sob 28 Maj 2011 15:19
Prispevkov: 29
Aktiv.: 0.17
Kraj: Ljubljana

PrispevekObjavljeno: Ned Jun 03, 2012 5:22 pm    Naslov sporočila:   Odgovori s citatom

Spet se mi je zataknilo, tokrat na 12F683.

Imam 3 dig. inpute (GP0, GP1, GP2). Kombinacija 111 naj bi vklopila izhod (GP4), kombinacija 001 pa izklopila. Zadeva mi ne špila (ledica stalno gori).

Uporabljam Int RC clkout, MCLR disabled. Sem pozabil naštimati še kake registre? Prilagam kodo in schematic.

Koda:

void main() {
     TRISIO = 0b00000111;
     CMCON0 = 0x07;     // comparators off
     ANSEL = 0;         // all i/o as digital

     while (1) {
         if ((GPIO & 0b00000111) == 0b00000111) GPIO == 0b00010000;
         else if ((GPIO & 0b00000111) == 0b00000001) GPIO == 0;
     }
}



12f683.png
 Opis:

Download
 Ime datoteke:  12f683.png
 Velikost datoteke:  4.8 KB
 Downloadano:  1 krat

Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
gumby
Član
Član



Pridružen-a: Sob 28 Apr 2007 12:32
Prispevkov: 4066
Aktiv.: 18.42

PrispevekObjavljeno: Ned Jun 03, 2012 5:31 pm    Naslov sporočila:   Odgovori s citatom

wicket je napisal/a:
Uporabljam Int RC clkout, MCLR disabled.

CLKOUT je na katerem pinu?

_________________
Tule nisem več aktiven.
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
wicket
Član
Član



Pridružen-a: Sob 28 Maj 2011 15:19
Prispevkov: 29
Aktiv.: 0.17
Kraj: Ljubljana

PrispevekObjavljeno: Ned Jun 03, 2012 5:49 pm    Naslov sporočila:   Odgovori s citatom

GP4. Če preklopim na GP5 je pa ledica stalno ugasnjena.
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
Pokaži sporočila:   
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> Microchip PIC Časovni pas GMT + 2 uri, srednjeevropski - poletni čas
Pojdi na stran 1, 2  Naslednja
Stran 1 od 2

 
Pojdi na:  
Ne, ne moreš dodajati novih tem v tem forumu
Ne, ne moreš odgovarjati na teme v tem forumu
Ne, ne moreš urejati svojih prispevkov v tem forumu
Ne, ne moreš brisati svojih prispevkov v tem forumu
Ne ne moreš glasovati v anketi v tem forumu
Ne, ne moreš pripeti datotek v tem forumu
Ne, ne moreš povleči datotek v tem forumu

Uptime: 492 dni


Powered by phpBB © 2001, 2005 phpBB Group