Assign different port bits to an array?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    <h1>Super !</h1>
    Happy it helped ! So many times, it seems my help isn't, but I try.

    "Trying is the first step toward failure". Homer Simpson
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    This should also work for what you are trying to do.

    Code:
    ' PORT OFFSETS
    '
    '
    '"A.0",0
    '"A.1",1
    '"A.2",2
    '"A.3",3
    '"A.4",4
    '"A.5",5
    '"A.6",6
    '"A.7",7
    '"B.0",8
    '"B.1",9
    '"B.2",10
    '"B.3",11
    '"B.4",12
    '"B.5",13
    '"B.6",14
    '"B.7",15
    '"C.0",16
    '"C.1",17
    '"C.2",18
    '"C.3",19
    '"C.4",20
    '"C.5",21
    '"C.6",22
    '"C.7",23
    '"D.0",24
    '"D.1",25
    '"D.2",26
    '"D.3",27
    '"D.4",28
    '"D.5",29
    '"D.6",30
    '"D.7",31
    '"E.0",32
    '"E.1",33
    '"E.2",34
    '"E.3",35
    '"E.4",36
    '"E.5",37
    '"E.6",38
    '"E.7",39
    '"F.0",40
    '"F.1",41
    '"F.2",42
    '"F.3",43
    '"F.4",44
    '"F.5",45
    '"F.6",46
    '"F.7",47
    '"G.0",48
    '"G.1",49
    '"G.2",50
    '"G.3",51
    '"G.4",52
    '"G.5",53
    '"G.6",54
    '"G.7",55
    '"H.0",56
    '"H.1",57
    '"H.2",58
    '"H.3",59
    '"H.4",60
    '"H.5",61
    '"H.6",62
    '"H.7",63
    '"J.0",64
    '"J.1",65
    '"J.2",66
    '"J.3",67
    '"J.4",68
    '"J.5",69
    '"J.6",70
    '"J.7",71
         
         For X = 0 to 10   
      
            Lookup X,[0,1,2,5,9,10,11,12,13,15,19,70],PortValue ; Put the bits you want to modify here, use table above
            
            Lookup X,[1,1,0,1,1,0,1,0,0,0,0],State ; put a 1 or a 0 here to determine state.
    
            TRISA.0(PortValue) = 0               ;Make it an output  
            PORTA.0(PortValue) = State        ;Set/Clear the bit             
         Next X
    Charles Linquist

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts