Pre-Compile TRIS

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

Pre-Compile TRIS

Post by gramo » Sun May 06, 2007 4:34 am

I just wanted to share this; I was rather wrapped by it when I found it in a system library;

Code: Select all

#option _Segment_Port = PORTC                      // Define the 7 Segment PORT
#option _Segment_TRIS = GetTRIS(_Segment_Port)     // Nice way to automatically get the TRIS of a PORT
                                                   //  automatically from a selected port
Dim
    Segment_Data As _Segment_Port,                 //  Make Alias’s from the compiler options
    Segment_TRIS As _Segment_TRIS


Segment_TRIS = %00000000                // Make the 7-segment pins all outputs
Segment_Data = %00000000                // And set them all low

Now you can setup the port for what ever device by only only changing the selected port ( _Segment_Port )

Its small features like the above that make it that much easier to make generic user modules a lot better
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

Post Reply