shoyur
Joined: 18 Oct 2008 Posts: 6
|
input problem |
Posted: Wed Jan 14, 2009 11:35 pm |
|
|
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 |
|