Welcome!
cool Welcome PIC fans!
(to Pascal language fans too!)
Technical

Close General documentation

Close How to support PMP

Close Manuals

Close Tips

Other stuff

Close Documentation

Close How to support PMP

Close Off Topic

Close Today's favourites

Search




Downloads
Tips - I/O direction

How to program outputs?

Just remember that a pin is an input if the corresponding bit in the associated TRISx register is set.
PMP has no specifiec built-in instruction for manipulating such register, simply affect a value directly to the register.

An example with TRISB:

TRISB := $­­­­­0F; // PORTB 0..3 as inputs, 4..7 as outputs
PORTB := $­­­­­F0; // set PORTB 4..7 high
TRISB.0 := false; // PORTB.0 as output, immediately set low (PORTB.0 was 0)
// Remember that every output pin has a latch even if it is set as an input, the latch works...

Manipulating the TRISx bit is a way to do fast 0 output with an external pullup (ofen used in bidirectional i/o such as I2C).

Another example with the full PMP syntax possibilities:

program test;
var


MyInputPin1 : boolean @PORTB.1;
MyInputPin2 : boolean @PORTB.4;
MyOutputPin1 : boolean @PORTB.2;

begin

TRISB := [MyInputPin1, MyInputPin1]; // set mask to pins that are inputs
MyOutputPin1 := MyInputPin1 or MyInputPin2;

end.

Help! There is no TRISx in my device!

For old and small devices that had no TRISx register, PMP (V1.05 and later) provides a special built-in procedure TRIS(Port, Mask) that maps to the TRISx register if it exists or to a TRIS instruction otherwise. The problem with TRIS instruction (of such device in fact) is that it is write only, you cannot read what is the current mask.


Creation date : 2007.06.22 7:37 PM
Last update : 2013.08.05 11:24 AM
Category : Tips
Page read 20344 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first to do so!


Connection...
 Members List Members : 75

Your Username:

Password:

[ Password lost ? ]


[ Join us ]


Member online :  Member online :
Anonymous online :  Anonymous online : 10

Total visits Total visits: 1572636  

Most ever online
Most ever onlineTotal : 170

The 01/01/2021 @ 17:50


Webmaster - Infos

Ip: 3.239.59.193

Search




Friends News
Where are you from?

Sentence to think about :  The enterprise's computing [...] is just like of an archaeological site. [...] Deep inside, you find real fossils, calcified: the punched card is no longer physically there,
but one can find
its "footprint" on the latest hard drives, up to traces of organization in eighty "columns".
  
Pierre Vandevingste, La Recherche, december 1996
^ Top ^