View previous topic :: View next topic |
Author |
Message |
xyzsor
Joined: 19 Dec 2010 Posts: 12
|
how to use PORTE and pinA4 of pic16f877a as output ? |
Posted: Mon Jan 31, 2011 10:18 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19365
|
|
Posted: Mon Jan 31, 2011 11:24 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Mon Jan 31, 2011 11:35 am |
|
|
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!!!! |
|
![](templates/subSilver/images/spacer.gif) |
xyzsor
Joined: 19 Dec 2010 Posts: 12
|
Thx |
Posted: Mon Jan 31, 2011 11:41 am |
|
|
Cool. I never knew it was that simple. Thanks Ttelmah for the heads up. People in this forum are very helpful. |
|
![](templates/subSilver/images/spacer.gif) |
|