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

input problem

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



Joined: 18 Oct 2008
Posts: 6

View user's profile Send private message

input problem
PostPosted: Wed Jan 14, 2009 11:35 pm     Reply with quote

Hi,

Weird problem -­>

a 16F876A, PCW 4.057 and a very simple circuit with 2 pushbuttons...
Code:

#include <16F876A.h>
#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD
#use delay(clock=20000000)
#include <LCD420.c>

void main() {
   int16 i;
      lcd_init();

      lcd_putc("\f 1 \n  2 \n 3 \n 4 ");
   

      while(1) {
      delay_ms(500);

         lcd_gotoxy(1,2);   //// 2e ligne
      if (input(PIN_C7)) { lcd_putc("BOUTON #2 (C7) : OUI"); }
      else { lcd_putc("BOUTON #2 (C7) : NON"); }

      lcd_gotoxy(1,3);   //// 3e ligne
      if (input(PIN_C6)) { lcd_putc("BOUTON #1 (C6) : OUI"); }
      else { lcd_putc("BOUTON #1 (C6) : NON"); }
      }   
}

and now I plug in and it says NON and NON but sometimes a OUI appear for some random seconds, if I push buttons, it works half the time, and most of the time the both OUI stay OUI by themself and come back to NON when they want, maybe 3 to 15 sec later .... the problem can't be my buttons, I use jumpers. Its a clean board, new and well used 20mhz oscillator, and stable constant 5.062V, and all wires not touching themself or wrecked.
I tried putting a i++ in my loop and lcd_putc the i to see if it increase each 500ms, it works, so its not a defect clocking ...

thank you Confused
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 14, 2009 11:55 pm     Reply with quote

Describe your pushbutton circuits.

You should have a pull-up resistor (4.7K or 10K) on pins C6 and C7.
Then one side of each push button switch should go to pin C6 or C7.
The other side of each switch should go to ground.
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