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

F628 port A0 and A1 not functioning as inputs

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







F628 port A0 and A1 not functioning as inputs
PostPosted: Sun Aug 01, 2004 3:29 pm     Reply with quote

Hello everyone,
I am using the F628 and am having a hard time reading A0 and A1.
I know there's analog comparators but I have turned those off.
I set the trisA to 0x03 (A0 and A1 as inputs) but yet I can't read them correctly.

This is part of the code:
[b]setup_counters(RTCC_INTERNAL,WDT_1152MS); //Set watchdog to reset uC after 1152ms
setup_timer_1(T1_DISABLED); //Disable Timer 1
setup_timer_2(T2_DISABLED,0,1); //Disable Timer 2
setup_comparator(FALSE); //Disable comparator
setup_vref(FALSE); //Disable comparator voltage reference

// Set Port A I/O direction register to 0000 0011 ///////////
set_tris_a(0x03); //Pins A0 and A1 are inputs, rest are outputs[b]

and then I try to read A1 (there's a high on this pin)
if(!input(A0))
{do something}

this piece of code should execute if A0 = 0 but it doesn't.
What's going on? What am I doing wrong?
Please advise,
OScar
Oscar
Guest







port A on F628
PostPosted: Sun Aug 01, 2004 3:31 pm     Reply with quote

This is a correction to the first message:

"and then I try to read A1 (there's a high on this pin)
if(!input(A0))
{do something} "

should read:
and then I try to read A1 (there's a high on this pin)
if(!input(A1))
{do something}

Oscar
Ttelmah
Guest







Re: F628 port A0 and A1 not functioning as inputs
PostPosted: Sun Aug 01, 2004 3:47 pm     Reply with quote

oscar wrote:
Hello everyone,
I am using the F628 and am having a hard time reading A0 and A1.
I know there's analog comparators but I have turned those off.
I set the trisA to 0x03 (A0 and A1 as inputs) but yet I can't read them correctly.

This is part of the code:
[b]setup_counters(RTCC_INTERNAL,WDT_1152MS); //Set watchdog to reset uC after 1152ms
setup_timer_1(T1_DISABLED); //Disable Timer 1
setup_timer_2(T2_DISABLED,0,1); //Disable Timer 2
setup_comparator(FALSE); //Disable comparator
setup_vref(FALSE); //Disable comparator voltage reference

// Set Port A I/O direction register to 0000 0011 ///////////
set_tris_a(0x03); //Pins A0 and A1 are inputs, rest are outputs[b]

and then I try to read A1 (there's a high on this pin)
if(!input(A0))
{do something}

this piece of code should execute if A0 = 0 but it doesn't.
What's going on? What am I doing wrong?
Please advise,
OScar

'False', is defined as 0. To disable the comparators, the code, is setup_comparator(NC_NC_NC_NC);
'0' gives the power on comparator reset mode, but does not disable them.
You then use 'input(A0)'. The port definition for pin A0, is PIN_A0. The result you will get will depend on whether you have an 'A0' defines somewhere.
Look at the .h file for the processor, it gives the variables to use with the functions, and is vital reading.

Best Wishes
Oscar
Guest







Thanks Ttehlma, that fixed my problem!!
PostPosted: Tue Aug 03, 2004 7:40 am     Reply with quote

Very Happy Very Happy
Ttelmah
Guest







Re: Thanks Ttehlma, that fixed my problem!!
PostPosted: Tue Aug 03, 2004 2:34 pm     Reply with quote

Oscar wrote:
Very Happy Very Happy

Glad it worked. :-)
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