setting port pins

Status
Not open for further replies.

P.Copper

Member level 5
Joined
Mar 18, 2013
Messages
82
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,807
Hi all

I'm a beginner when it comes to coding in C. How do i set a single port pin as output using C. i know in assembly we set it using "bsf PORTB,0 " syntax. how do i do the same thing using C? thanks
 

If you are using C30 compiler then, TRIS registers are there which are used as direction registers. If you want to use 0th pin of PORTB as a output then TRISBbits.TRISB0=0;
for input TRISBbits.TRISB0=1; same for other ports. But check first that default setting for pins.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…