View previous topic :: View next topic |
Author |
Message |
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
PIC18F452 problem with Port A I/O |
Posted: Fri Sep 23, 2005 3:24 pm |
|
|
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
|
|
|
jseidmann
Joined: 04 Nov 2004 Posts: 67
|
But does it work like a regular I/O pin? |
Posted: Sat Sep 24, 2005 7:04 am |
|
|
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
|
|
Posted: Sat Sep 24, 2005 11:52 am |
|
|
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. |
|
|
|