Implicit Definition Of A Pin

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Implicit Definition Of A Pin

Post by Widgetman » Sun Jan 13, 2008 3:52 pm

Hi All,
I know it is probably a silly question, but I need to know how to Implicitally define a I/O pin as a Input on a PIC part to make sure it comes up correctly. I could not find any example. Any help would be greatly appreciated.
Thanks

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Jan 13, 2008 4:25 pm

Its a pic related question You need to set the tris register

trisx.x = 1

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

Post by octal » Sun Jan 13, 2008 4:32 pm

Hi,
as Tim stated you can use

Code: Select all

//Pins numbering is zero based
TrisA.3 = 1    '<<< makes Pin3 on PortA as Input
TrisB.5 = 0    '<<< makes Pin5 on PortB as Output

' For all Port you may set all TRISx in one shot "1" or Input "0" for Output
 TrisB = %01001110

or you can simply use the Input()/Output() predefined subs

From Swordfish Help in Topic
Language Reference>>Predefined Subroutines and Functions

Input
sub input(byref portpin as bit)

The input subroutine makes the specified port pin an input. For example,

input(PORTD.7)

Output
sub output(byref portpin as bit)

The output subroutine makes the specified port pin an output. For example,

output(PORTD.7)

Regards
octal

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Implicit Definition

Post by Widgetman » Sun Jan 13, 2008 9:09 pm

Thanks a bunch guys !!!!!

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Post by Widgetman » Sun Jan 13, 2008 9:33 pm

Hi,
I tried what you suggested and got a compile error. I was wondering if there is a #option command to set say PORTA.3 as Input

I tried dim PORTA.3 as Input and got a compile error on the next line complaining about no end statement
Any ideas ?

I would like to define certain pins in my code to be specific

Thanks

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Jan 13, 2008 10:07 pm

Dim is an alias to one or more registers it does nothing to the pic

Trisx.x = 1 or input(portx.x) is a implicit command and will make the pic pin an input

If you want to use dim then use

dim xxx as portx.x then issue
input(xxx)

Or
Dim xxx as trisx.x and issue
xxx = 1

Widgetman
Posts: 136
Joined: Sun Dec 16, 2007 7:39 pm
Location: Florida

Post by Widgetman » Sun Jan 13, 2008 10:58 pm

Hi,
Thanks again for the help
I got it to work by using Input(PORTX.X)
I did notice however I had to place the Input command after my sub routines or it would not compile. I am not sure why

TimB
Posts: 262
Joined: Wed Oct 04, 2006 7:25 am
Location: London UK

Post by TimB » Sun Jan 13, 2008 11:26 pm

I did notice however I had to place the Input command after my sub routines or it would not compile. I am not sure why
That's the way the compiler works All subs etc before main commands.

Post Reply