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

PIC18F452 problem with Port A I/O

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



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

PIC18F452 problem with Port A I/O
PostPosted: Fri Sep 23, 2005 3:24 pm     Reply with quote

I am using a board that has a PIC18F452 and I am trying to be able to change the value of RA4. In the code, the value of that pin is toggled every minute, and the value of tris is:

set_tris_a(0b00001111);

In the code, it also says:

setup_adc_ports(RA0_RA1_ANALOG_RA3_REF);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(0);

I am wondering how I can have Pin 4 be an output and actually be able to toggle its value. I have kind of inherited this code and I'm not sure what to do. The TRIS value seems to set RA4 as an output, but I can't get it to output anything, and on startup I have the line "output_high(PIN_A4)".

Does anyone have any ideas of what I can do??

Thanks,

Seidleroni
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 23, 2005 3:48 pm     Reply with quote

http://pw2.netcom.com/~fastfwd/answers.html#PIC00085
http://www.piclist.com/techref/microchip/portpins.htm
jseidmann



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

But does it work like a regular I/O pin?
PostPosted: Sat Sep 24, 2005 7:04 am     Reply with quote

To switch between open collector and tri-state, can I control that functionality like a regular pin using the output_low(PIN_RA4) and output_high(RA4) to switch between the two?

The reason I'm asking is this: I want to use this pin to toggle an LED (it has to be this pin, i've inherited the hardware) The LED is positioned in such a way that it always has 5V on one terminal (with a resistor in series of course) and then going into pin RA4. Is it possible to toggle the LED by switching between tri-state and open drain? If so, can I do this using the I/O commands I stated in the first paragraph?

Thanks! You guys on this forum have been a HUGE help to me. Your help is mucho appreciated.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 24, 2005 11:52 am     Reply with quote

Quote:
To switch between open collector and tri-state, can I control that
functionality like a regular pin using the output_low(PIN_A4) and output_high(PIN_A4) to switch between the two?

That's correct.
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