Andreas
Joined: 25 Oct 2004 Posts: 136
|
HELP Capacitive Touch PIC16F726 |
Posted: Sat Sep 08, 2012 8:54 am |
|
|
Hello Friends
I am running into a problem which drives me crazy.
I started a test for the touchpad features of this compiler, fancy enough it was working. I'm at the beginning but after some iterations I even can't get the easiest program to run.
Here is my code:
Code: |
#include <16F726.h>
//#device ICD=TRUE
#fuses HS,NOWDT
#use delay(INTERNAL=8MHz)
#use touchpad(range = 18,scantime=32ms,threshold = 6,pin_b4='0',pin_b5 ='1',pin_a4='2',pin_a5 ='3')
#define num 2
#define OUT1 PIN_B0
INT i;
void main()
{
enable_interrupts(GLOBAL);
//touchpad_state(1);
while(TRUE)
{
if(touchpad_hit())
{
i= touchpad_getc();
switch (i)
{
case '1':output_high(OUT1);break;
case '2':output_low(OUT1);break;
case '3': output_high(OUT1);break;
case '0': output_low(OUT1);break;
}
}
}
}
|
So what is the problem ??
It works every time after the reset only once. I mean for one key, doesn't matter which one and after that it never detects a touchpad_hit !!!
I already read all forum posts with touch, but couldn't find any helpful answer.
Compiler Version: CCS PCM C Compiler, Version 4.107, 48988
OOPS: Pads are connected to Port A4,A5,B4,B5
Any suggestions are appreciated.
Best regards from Austria
Andreas |
|