Dim pin1 as PORTA.0 reusing in module

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Dim pin1 as PORTA.0 reusing in module

Post by be80be » Mon Feb 21, 2011 3:30 am

I have 16 pins on two ports I want to rename them to simple pin1 to pin16 and not have to remember what port it is just what pin I'm using.

If I just do a dim pin1 to 16 as PORT.X at the beginning and then add all the testing subs would this be the best way to go?

So when I test the pins with a sub like this it will use the pin naming

Code: Select all


//Triple 3-input AND gates 74ls11
sub T74ls11 ()
Dim good As Boolean 
Low (pin1) 
Low (pin2)
Low (pin13)
Input (pin12) 
    If pin12 = 0 Then
       good = true
    EndIf 
          DelayMS(500) //so we don't miss ant thing 
High (pin1) 
Low (pin2)
Low (pin13) 
    If pin12 = 0 Then
        good = true
    EndIf 
         DelayMS(500) //so we don't miss ant thing 
High (pin1) 
High (pin2)
High (pin13)
     If pin12 = 1 Then
         good = true
     EndIf
     If good = true Then 
        High (PORTA.0)
     Else 
           good = false // was bad
          Low (PORTA.0)
     EndIf 
end sub
// Next test 

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Mon Feb 21, 2011 7:06 am

the best place to learn how to do that the correct way is check library modules' source codes!
All lib modules use OPTION and DIM statements to make such things happen ;)

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Feb 21, 2011 11:34 am

That's a great Idea but what I"m looking for wasn't in there.

The whole problem was the subs name I changed that. You can't name subs
74ls11 you can name them T74ls11

Thanks

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Mon Feb 21, 2011 3:35 pm

ALL PICs use the Port(Letter).# assignments.

If you get into learning one PIC by pin number, if you ever move to another PIC you'll waste even more time doing the same thing for that one.

Additionally, all of the specifications from the manufacturer use Port assignments (as well as most 3rd party guides which follow the specs). Having spent a few years doing this, I'd suggest just learning to follow the specs; as it will result in far easier transitions to other PICs later.

Oh, and have fun.
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Mon Feb 21, 2011 7:46 pm

I don't need a all pic has PortA PORTB I No that what I 'm hooking to the pic you don't no the numbers there just pins 1 to 16 I have about 50 pages of subs when I'm done I want to cut as many things out as can be

And it wasn't letting me because of the name

I had it 74ls11 You cant name a sub starting with numbers

So I changed it to T74ls11

Post Reply