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

258 pin bo not an input

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







258 pin bo not an input
PostPosted: Mon Jun 07, 2004 9:29 am     Reply with quote

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
PostPosted: Mon Jun 07, 2004 9:45 am     Reply with quote

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: 1912
Location: Norman, OK

View user's profile Send private message

Port B
PostPosted: Mon Jun 07, 2004 9:53 am     Reply with quote

Did you turn off the Port B Pullups?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Jun 07, 2004 9:59 am     Reply with quote

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







PostPosted: Mon Jun 07, 2004 11:43 am     Reply with quote

i tried to pull it down with a 1 k resistor and it remains high ball other portb pors are ok
drolleman
Guest







PostPosted: Mon Jun 07, 2004 11:52 am     Reply with quote

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
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