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

IO Ports as Input
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Fri Aug 01, 2014 6:28 am     Reply with quote

When you "turn off power" your pull-up resistor becomes a pull-down resistor.
What else may happen depends on what the rest of your circuit looks like and how everything is powered.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Aug 01, 2014 6:36 am     Reply with quote

simple RF suppression:

pull-up resistor =10k ohm
parallel capacitor = 10nF

capacitor is placed across the switch terminals
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 01, 2014 2:05 pm     Reply with quote

Sterngleiter wrote:
it's just like having drawn alan.

I don't think so. In your previous post, you said this:
Sterngleiter wrote:
It's pulled low.

Then your code below, waits for the pin to go high (when the button is
pressed), and then counts up 'test' while the pin is high:
Code:
while(true)
  {
   if(input(pin_a1)==1)
     {
      while(input(pin_a1)==1);

      ++test;
     }
  }


So I strongly suspect that it's really connected like this:
Code:
             
                     Switch     +5v     
                      ___        |
To                   _|_|_       |
PIC --------o--------o   o-------o
pin         |                               
            <                   
            > 4.7K                     
            <
            |
           --- GND
            -


If this is not an accurate description of your circuit, then post a schematic
that shows exactly what you have. Show all component values.
Sterngleiter



Joined: 07 Jan 2013
Posts: 90

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 11:34 am     Reply with quote

Hi, Thank You for so many tips. I thought software debouncing would be enough but unfortunately I have to debounce Hardware
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 3:27 pm     Reply with quote

Software debouncing is usually sufficient.

The problem all along has been you have adamantly refused to give us enough information to work on.
You say problem is now solved, that's good, but I still can't work out what the real problem was, hence my opt-out earlier.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Aug 05, 2014 5:17 pm     Reply with quote

magic......
it would be nice to see the schematic and code for your solution
it'll help others in the future as it's a common problem...

jay
joergn



Joined: 15 Jul 2010
Posts: 15
Location: Hamburg Germany

View user's profile Send private message Visit poster's website

PostPosted: Fri Aug 08, 2014 3:11 am     Reply with quote

Code:
while(true)
  {
   if(input(pin_a1)==1)
     {
      while(input(pin_a1)==1);
     }
      ++test;   // should count only when button is released or changed
  }


Polling should not eat up all MCU power , so put it inside a timer
loop.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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