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

Rx & A/D_input in the same PIN

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



Joined: 08 Jun 2006
Posts: 14

View user's profile Send private message

Rx & A/D_input in the same PIN
PostPosted: Wed Jun 13, 2007 6:46 am     Reply with quote

We have a little problem here.
PIC16F88

I need to use pin_a4 as Rx input when the PIC is comunicating to the PC but, I need this pin to be an A/D input when the PIC is not comunicating to the PC. This circuit comunicates to the PC when an interrupt performs an int_function(); Although I am not trying to use them at the same time, I am unable to alternate the function of this pin.

#use rs232(baud=38400,xmit=pin_a2,rcv=pin_a4)
then, inside the main() I use.
setup_adc_ports(sAN4|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_16);
set_adc_channel(4);

of course, wen computer comunicaction starts because interrupt excecutes int_function(), it does not work. What do you think should I write/do inside int_function() to change the behavior from AD channel to Rx input

Could any body?
Thankyou very much
Ivan Perino
Ttelmah
Guest







PostPosted: Wed Jun 13, 2007 7:22 am     Reply with quote

You will need to add:
setup_adc_ports(NO_ANALOGS);

Before trying to use the pin for digital input, and then set the port for analog I/O again when finished.
If you look at the block diagram in the data sheet, for the I/O pin, you will see that the input TTL buffer is disabled, when analog moe is selected.
Obviously, you are going to need to be careful with the external connections, to ensure that only one signal at a time is connected...

Best Wishes
ivanperino



Joined: 08 Jun 2006
Posts: 14

View user's profile Send private message

PostPosted: Wed Jun 13, 2007 4:28 pm     Reply with quote

It worked ok.
Thank you a lot. It has been very useful to me.
it is easy to design with people like you.
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