CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Setting the pins as input or output of PIC12F675

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
darryl_co



Joined: 11 Nov 2015
Posts: 21
Location: India

View user's profile Send private message

Setting the pins as input or output of PIC12F675
PostPosted: Sun Nov 29, 2015 3:17 pm     Reply with quote

Please help me set the pins of 12F675 as input or output .
GP0 and GP3 input and rest output.This is one example
Code:
set_tris_a( 0b11111101 ); // set GP1 output, all other inputs

How to enable pull up for inputs?
How to set all outputs to low?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 29, 2015 5:18 pm     Reply with quote

Download the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in this section:
Quote:
General Purpose I/O

It's on page 59 in the Acrobat Reader (page 49 on the actual page).
darryl_co



Joined: 11 Nov 2015
Posts: 21
Location: India

View user's profile Send private message

PostPosted: Sun Nov 29, 2015 11:23 pm     Reply with quote

I do have that manual. I searched it but was still not able to understand so I requested for example. The pic is 8 bit. GP0, 1,2,4,5 are input /output and GP3 is MCLR pin only input
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 30, 2015 12:09 am     Reply with quote

Code:
#include <12F675.h>
#fuses INTRC_IO, NOWDT, NOMCLR
#use delay(clock=4M)

//==========================
void main()     
{
set_tris_a(0x09);

port_a_pullups(0x3F);

output_a(0);

while(TRUE);   
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19381

View user's profile Send private message

PostPosted: Mon Nov 30, 2015 1:13 am     Reply with quote

The only problem here is after the 'output_a(0)' statement, the port will all be set as output, except PIN_A3. So TRIS will actually be set as 0x8 at the end of the program.

Have a look at this thread:
<http://www.ccsinfo.com/forum/viewtopic.php?t=54597>

The output statement will override the earlier TRIS statement.

Understand that in general, you hardly ever actually have to set the TRIS with CCS C. If you just input from the pins you want as inputs, and output to the pins you want as output, CCS will automatically set the TRIS for you.
darryl_co



Joined: 11 Nov 2015
Posts: 21
Location: India

View user's profile Send private message

PostPosted: Mon Nov 30, 2015 11:08 am     Reply with quote

One More help. for the code
output_toggle(GP1);
how to get
GP2=!GP1
if gp1 is high than gp2 is low
Ttelmah



Joined: 11 Mar 2010
Posts: 19381

View user's profile Send private message

PostPosted: Mon Nov 30, 2015 11:13 am     Reply with quote

output_bit(PIN_A2, !input(PIN_A1));
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group