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

12F1840 & Touchpad Library

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



Joined: 27 Mar 2012
Posts: 4

View user's profile Send private message

12F1840 & Touchpad Library
PostPosted: Tue Mar 27, 2012 4:47 am     Reply with quote

I try to use TOUCHPAD library with 12F1840. When I use only PIN_A2 all is OK, but when I declare
#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='A', PIN_A4='B')
Touch buttons doesn't works. Compiler 4.130. Source code:
Code:

#include <12LF1840.h>
#include <regPIC12LF1840.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES WDT_SW                   //No Watch Dog Timer, enabled in Software
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=16000000)

#use FIXED_IO( A_outputs=PIN_A0)
#define LED   PIN_A0

#USE TOUCHPAD(RANGE=H, THRESHOLD=15, SCANTIME=32, PIN_A2='B')
//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')

char c;

void main(void){
   setup_oscillator(OSC_16MHZ|OSC_NORMAL|OSC_PLL_OFF,0);

   enable_interrupts(GLOBAL);
   touchpad_state(1);

   while(1){
       c = TOUCHPAD_GETC();
   
      if(c == 'B' || c=='A'){
         c=0;
         output_toggle(LED);
         output_toggle(PIN_A4);
         delay_ms(100);
      }
   }
   
}

I think there's some bug in CCS library. Some ideas ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 27, 2012 1:22 pm     Reply with quote

Quote:

//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')


void main(void){

if(c == 'B' || c=='A'){
c=0;
output_toggle(LED);
output_toggle(PIN_A4);
delay_ms(100);
}
}

}

You are toggling Pin A4. That's the same pin that you assigned as
a Touchpad input. Don't toggle a pin that is used for the touchpad.
Don't do anything to it. It's controlled by the Touchpad library code.
longos



Joined: 27 Mar 2012
Posts: 4

View user's profile Send private message

PostPosted: Wed Mar 28, 2012 3:55 am     Reply with quote

PCM programmer wrote:
Quote:

//#USE TOUCHPAD(RANGE=H, THRESHOLD=6, SCANTIME=32, PIN_A2='B', PIN_A4='A')

You are toggling Pin A4.
This line is in comment. I use only PIN_A2.
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