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 CCS Technical Support

how to use PORTE and pinA4 of pic16f877a as output ?

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



Joined: 19 Dec 2010
Posts: 12

View user's profile Send private message Visit poster's website

how to use PORTE and pinA4 of pic16f877a as output ?
PostPosted: Mon Jan 31, 2011 10:18 am     Reply with quote

Hi guys. I'm quite new in uC programming. I'm using a pic16f877a.

I need to use pin A4 and port E as a TTL output.

Is that possible? What configurations do I need to set?

The only ones I triggered are the ff.
Code:
 
#byte porta=5                /* defines memory location of register */
#byte porte=9                /* defines memory location of register */

set_tris_a(0x00);
set_tris_e(0x00);

Thanks in advance to anyone who helps.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 11:24 am     Reply with quote

You don't need any of what you have posted.
Just:
Code:

output_a(value);
output_e(value);

Where 'value' is what you want to output. The compiler does _all_ the nitty gritty stuff for you, setting the TRIS automatically, and outputting the value to the right port.
On your chip, A4, is a 'pull down' pin only. You have to add an external pullup resistor to use it as a normal output.
On portE, make sure you have turned off the PSP.

Best Wishes
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 11:35 am     Reply with quote

They might need to turn off the comparators and ADCs

Code:

setup_adc(ADC_OFF);
setup_comparator(NC_NC_NC);
 

_________________
Google and Forum Search are some of your best tools!!!!
xyzsor



Joined: 19 Dec 2010
Posts: 12

View user's profile Send private message Visit poster's website

Thx
PostPosted: Mon Jan 31, 2011 11:41 am     Reply with quote

Cool. I never knew it was that simple. Thanks Ttelmah for the heads up. People in this forum are very helpful.
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