View previous topic :: View next topic |
Author |
Message |
drolleman Guest
|
258 pin bo not an input |
Posted: Mon Jun 07, 2004 9:29 am |
|
|
can someone help i have tried to get b0 to go as an input but won't. i created aq tiny app to prove the point
#include <18f258.h>
main()
{
output_float(pin_b0); --> high
output_low(pin_b0);--> low
output_float(pin_b0); --> high
input(pin_b0);--> high
input(pin_b0);--> high
input(pin_b0);--> high
}
trisb and portb are showing the correct values. port b changes as the output changes, trisb shows input when input is selected but the pin is always output? and when i call for input the pin goes high. |
|
|
Ttelmah Guest
|
Re: 258 pin bo not an input |
Posted: Mon Jun 07, 2004 9:45 am |
|
|
drolleman wrote: | can someone help i have tried to get b0 to go as an input but won't. i created aq tiny app to prove the point
#include <18f258.h>
main()
{
output_float(pin_b0); --> high
output_low(pin_b0);--> low
output_float(pin_b0); --> high
input(pin_b0);--> high
input(pin_b0);--> high
input(pin_b0);--> high
}
trisb and portb are showing the correct values. port b changes as the output changes, trisb shows input when input is selected but the pin is always output? and when i call for input the pin goes high. |
And have you actually tried pulling the pin down when it is set as an input, and reading it?.
Try adding 'port_b_pullups(false);'. Though the pull-ups are supposed to be disabled on power-on, it is possible that the compiler is defaulting to enabling them. However even when disabled, there can be a very slight pull-up effect, and the pin may well drift high. What else is attached to the pin?. Remember that if the pin connects to a TTL input, or something like a LED with a pull-up resistor, it will float high.
Best Wishes |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
Port B |
Posted: Mon Jun 07, 2004 9:53 am |
|
|
Did you turn off the Port B Pullups? |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Mon Jun 07, 2004 9:59 am |
|
|
If that listing is the entire code that you have, and not just a snippit, then I don't think it will show you anything.
Try this:
If you have anything tied to the rest of PortB then make sure you have NOLVP in your #fuses statement.
Code: |
main()
{
while(1)// we don't want the PIC to fall asleep, now do we
{
if(!input(PIN_B0))// is the pin being pulled low?
{
output_low(PIN_B1);// let's drive this pin low too then
}
else// if B0 is NOT being pulled low
{
output_high(PIN_B1);// then let's drive the output high
}
}
}
|
Put a pull-up resistor on B0 and then try toggling it high and low. Measure the output on B1 to see if it toggles with your input. If it works then you know that it's working as an input.
Ronald |
|
|
drolle man Guest
|
|
Posted: Mon Jun 07, 2004 11:43 am |
|
|
i tried to pull it down with a 1 k resistor and it remains high ball other portb pors are ok |
|
|
drolleman Guest
|
|
Posted: Mon Jun 07, 2004 11:52 am |
|
|
that was a garbled response
this is a test program that is to prove one point of port b0
using a icd2 in debug mode
i have put a resistor 1k on b0 to gnd when high and then +5 when low and same results it is and output. when testing after input statement i check the pin and it is an output in debug and single step on icd2. the scope shows the pin going low when the statement has output(pin_b0) but when the statement output_float or input(pin_b0) is run the pin goes high |
|
|
|