|
|
View previous topic :: View next topic |
Author |
Message |
oscar Guest
|
F628 port A0 and A1 not functioning as inputs |
Posted: Sun Aug 01, 2004 3:29 pm |
|
|
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 |
Posted: Sun Aug 01, 2004 3:31 pm |
|
|
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 |
Posted: Sun Aug 01, 2004 3:47 pm |
|
|
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!! |
Posted: Tue Aug 03, 2004 7:40 am |
|
|
|
|
|
Ttelmah Guest
|
Re: Thanks Ttehlma, that fixed my problem!! |
Posted: Tue Aug 03, 2004 2:34 pm |
|
|
Oscar wrote: | |
Glad it worked. :-) |
|
|
|
|
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
|