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

Capsense issues with Pic16f1939

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



Joined: 02 Aug 2010
Posts: 30

View user's profile Send private message

Capsense issues with Pic16f1939
PostPosted: Tue Mar 27, 2012 4:05 pm     Reply with quote

Hello,

Ever since I migrated from the Pic16f727 to the Pic16f1939 I started having problems with the capsense sensitivity. The capsense module won't detect a finger press with an overlay anymore. It seems it's much less sensitive and even if I push the scan time to the max the module won't detect any finger press.

Here is the code and like I said it worked fine with the Pic16f727
Compiler version 4.128. Any idea how to resolve the sensitivity issue is appreciated. Thank you

Code:

#include <16F1939.h>
#fuses   INTRC_IO, NOWDT, NOPROTECT, NOMCLR,VCAP_A6
#use     delay(clock = 8000000)
#include "flex_lcd.c"

// use the manual way for assigning IO pins
#use     fast_io (C) 
                                       //CAP1      CAP2       CAP4       CAP10      CAP9
#use touchpad(scantime=67ms threshold=3,PIN_D1='5',PIN_D2='4',PIN_D0='3',PIN_D4='2',PIN_D3='1')
                                      //PIN_D1='1',PIN_D2='2',PIN_D5='3',PIN_D0='4',PIN_D4='5'


//------------------------------
//gloable variable declaration
//------------------------------
char c='0';
char previous_sensor_id=0;
char current_sensor_id;
char user_selection;
int8  scroller=0;
int8 display_delay=8;
//---------------------------------------------------
//function prototypes:
//---------------------------------------------------
int8 scroll_wheel_value(void);
void make_LCD_pins_digital(void);


void main(void)
{
   make_LCD_pins_digital();
   lcd_init();
   lcd_putc("\fTime \n");
   lcd_putc(" Calibrating ");
   delay_ms(200);
   enable_interrupts(GLOBAL);
   //calibrates, then enters normal state
   TOUCHPAD_STATE(1);

  do
   {
   scroll_wheel_value();
   switch (c)
    { 
   
      //start time lapse;
      case '5':
      printf(lcd_putc,"\f%c%s",126,"Start TM ");
      lcd_putc("\n Set Time Date");     
      user_selection='5';
      delay_ms(display_delay);
      //IR OUT 
      //GPIOD_5=1;
      //delay_ms(10);
      break;
     
      case '1' :
      lcd_putc("\f Start ");
      printf(lcd_putc,"\n%c%s",126,"Set Time Date");
      user_selection='1';
      delay_ms(display_delay);
      break;
     
      case '2':
      lcd_putc("\f Set Time Date");
      printf(lcd_putc,"\n%c%s",126,"expo");
      user_selection='2';
      delay_ms(display_delay); 
      break;
     
      case '3':
      lcd_putc("\f exposure");
      printf(lcd_putc,"\n%c%s",126,"Trigger");
      //printf(lcd_putc,"\n%c%s",126,"Motion
      user_selection='3';
      delay_ms(display_delay); 
      break;
     
      case '4':
      lcd_putc("\f Trigger");
      //lcd_putc("\f lapse");
      printf(lcd_putc,"\n%c%s",126,"Setting");
      user_selection='4';
      delay_ms(display_delay);
      break;
    }

    }while(1);
   
}
int8 scroll_wheel_value(void)
 {

    if(touchpad_hit())
     {
       c=touchpad_getc();
      //lcd_putc("\ftouchpad pressed");
      current_sensor_id=c;
      if (current_sensor_id > previous_sensor_id)
        {
         if ((current_sensor_id=='5')&&(previous_sensor_id=='1'))
          {
          --scroller;
          }   
          else
          {
          ++scroller;

          }
        }
     else if ((current_sensor_id < previous_sensor_id))
        {
          if ((current_sensor_id=='1')&&(previous_sensor_id=='5'))
           {
           ++scroller;
           }
         else 
          {
          --scroller;
     
          }   
       }
       previous_sensor_id=c;     
     }
     else
     {
     //c='0';
     return(scroller);                   
     }
  return(scroller);
 }

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