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

Capacitive sensing module built-in function not working

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



Joined: 16 Jul 2009
Posts: 19
Location: Sherbrooke, Québec, Canada

View user's profile Send private message Visit poster's website

Capacitive sensing module built-in function not working
PostPosted: Tue Mar 23, 2010 7:38 pm     Reply with quote

This thread talks about mTouch capacitive sensing module (CSM) built in function by CCS not working with a specific PIC.

functions used are:
Code:

touchpad_state( )
touchpad_getc( )
touchpad_hit( )
#USE TOUCHPAD ( )

The compiler version is V4.104

The PIC I am using is 16LF722.

I saw this code here
http://www.ccsinfo.com/content.php?page=V4.1xx
and tested it.

Here is the code:
Code:

#include <16lf727.h>
#fuses INTRC_IO,NOWDT
#use delay(INTERNAL=8Mhz)
#use rs232(baud=9600,rcv=PIN_E0,xmit=PIN_E1)

#use touchpad(scantime=32ms,threshold=6,PIN_B1='0',PIN_B0='1',PIN_D7='2',PIN_D0='3')

void main()
{
   char c;

   enable_interrupts(GLOBAL);
   
   while(TRUE)
   {
      if(touchpad_hit())
      {
         c=touchpad_getc();
         putc(c);
      }
   }
}


I compiled the code and got this
Quote:

>>> Warning 202 "capacitive_main.c" Line 6(5,8): Variable never used: TOUCHPADSTATUS
>>> Warning 202 "capacitive_main.c" Line 6(5,8): Variable never used: TOUCHDATA
Memory usage: ROM=4% RAM=13% - 13%
0 Errors, 2 Warnings.
BUILD SUCCEEDED

Everything seems fine, so I when for the next step, using my PIC the 16LF722 instead of the 16LF727.
I change the include and also change the device in MPLAB, I had to change the pins on the RS-232 since the 16LF722 does not have E0 and E1.

Here is the code:
Code:
#include <16lf722.h>
#fuses INTRC_IO,NOWDT
#use delay(INTERNAL=8Mhz)
#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)

#use touchpad(scantime=32ms,threshold=6,PIN_B1='0',PIN_B0='1',PIN_D7='2',PIN_D0='3')

void main()
{
   char c;

   enable_interrupts(GLOBAL);
   
   while(TRUE)
   {
      if(touchpad_hit())
      {
         c=touchpad_getc();
         putc(c);
      }
   }
}


I then compile and get this
Quote:

*** Error 99 "capacitive_main.c" Line 6(5,85): Option invalid Bad Pin: 49
*** Error 12 "capacitive_main.c" Line 16(22,23): Undefined identifier -- touchpad_hit
*** Error 12 "capacitive_main.c" Line 18(25,26): Undefined identifier -- touchpad_getc
3 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED:

I get the error message saying Bad pin 49 which is B1. If I delete PIN_B1='0', I will get bad pin 48 because B0 is the next one.

Here is the pin numbers from the PIC16LF722.H file
Code:

#define PIN_B0  48
#define PIN_B1  49
#define PIN_B2  50
#define PIN_B3  51
#define PIN_B4  52
#define PIN_B5  53
#define PIN_B6  54
#define PIN_B7  55


In the datasheet, most of the CSM pins are located on port B. I also tried with port A and got no luck.

I don't understand why it seems to work on the 16LF727 and not the 16LF722.
How can I know if that is a CCS compiler error ?
or maybe a human error...

I also tried all the 16F7XX series and got all the same errors except the 16F727.
16F722
16F723
16F726
16F727

Also, on page 163 of the PDF or page 152 of manual, there is the #use touchpad.
http://www.ccsinfo.com/downloads/PCDReferenceManual.pdf

Why does it said warning on "TOUCHPADSTATUS" and "TOUCHDATA" if there are not part of the
element you should write in the parameter?

You can no find "TOUCHPADSTATUS" and "TOUCHDATA" in the PDF when you search it. Not even in the .h file.

Any clue?

Thank for all your help.

Jerome
_________________
Jérôme Demers
www.jeromedemers.com
robomaniac



Joined: 16 Jul 2009
Posts: 19
Location: Sherbrooke, Québec, Canada

View user's profile Send private message Visit poster's website

PostPosted: Tue Mar 23, 2010 11:33 pm     Reply with quote

V4.105 did not help either!

I am also testing only this

Code:
#use touchpad(scantime=32ms,threshold=6,PIN_A5='C')


and tried different pins and getting the same error.
_________________
Jérôme Demers
www.jeromedemers.com
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Wed Mar 24, 2010 3:21 am     Reply with quote

Do you have the windows compiler, or the command line one.
If the latter, moan to CCS.
If the former, select tools, device editor, select your chip, middle column, 'other features', set 'Cp Sense Mod' to 'true'.

You will still get a problem, since the 722, does not have pins D0, or D7, but if you chose pins that it does have, it'll then compile OK.

You should report it to CCS anyway, they just haven't enabled the module on this chip.

Best Wishes
robomaniac



Joined: 16 Jul 2009
Posts: 19
Location: Sherbrooke, Québec, Canada

View user's profile Send private message Visit poster's website

PostPosted: Wed Mar 24, 2010 10:13 am     Reply with quote

Hello Ttelmah,

I never use CCS IDE, so I tried and change that bit so my module is turn ON. It compiled OK.
I was not able to program the circuit with my ICD3 using CCS IDE. I get DDL version mis-match and Target Run Error: The HTOOL is invalid

so I loaded the hex file with MPLAB.

With some little fine adjustement to my code it WORKS!!

It is amazing! I love PIC!

Thank you for your help!
I will contact CCS with that problem.

here is the final code:
Code:
/*
http://www.ccsinfo.com/forum/viewtopic.php?t=42107
http://www.ccsinfo.com/forum/viewtopic.php?t=37024&highlight=mtouch
Built-in mTouch™ capacative sensing module

*/
#include <16lf722.h>

#fuses INTRC_IO,NOWDT,VCAP_A5
#use delay(INTERNAL=8Mhz)

#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#use touchpad(scantime=32ms,threshold=6,PIN_B0='C',PIN_B1='5',PIN_B3='3')

#define GREEN_LED1   PIN_C2
#define GREEN_LED2   PIN_C3

//=========================

void main(void)
{
   char c;

   enable_interrupts(GLOBAL);

   output_high(GREEN_LED1);
   output_high(GREEN_LED2);
   delay_ms(300);
   output_low(GREEN_LED1);
   output_low(GREEN_LED2);

   while(1)
   {
      //   TOUCHPAD_STATE(1); //calibrates, then enters normal state
            if(touchpad_hit())
            {
               c=touchpad_getc();
               putc(c);
               
               if(c=='C')
                  output_toggle(GREEN_LED1);
   
               if(c=='5')
                  output_toggle(GREEN_LED2);
            }// end if
       
   } // end while
}// main

_________________
Jérôme Demers
www.jeromedemers.com
mglsoft



Joined: 18 Feb 2008
Posts: 48

View user's profile Send private message

PostPosted: Tue Jul 02, 2013 6:41 am     Reply with quote

Ttelmah wrote:
Do you have the windows compiler, or the command line one.
If the latter, moan to CCS.
If the former, select tools, device editor, select your chip, middle column, 'other features', set 'Cp Sense Mod' to 'true'.

You will still get a problem, since the 722, does not have pins D0, or D7, but if you chose pins that it does have, it'll then compile OK.

You should report it to CCS anyway, they just haven't enabled the module on this chip.

Best Wishes



Idea Idea Idea Idea
_________________
MGLSOFT
ricperez



Joined: 25 Apr 2007
Posts: 14

View user's profile Send private message

Will this solution work with PIC18F66K80? it has CTMU...
PostPosted: Tue Oct 06, 2015 11:56 am     Reply with quote

robomaniac wrote:
Hello Ttelmah,

I never use CCS IDE, so I tried and change that bit so my module is turn ON. It compiled OK.
I was not able to program the circuit with my ICD3 using CCS IDE. I get DDL version mis-match and Target Run Error: The HTOOL is invalid

so I loaded the hex file with MPLAB.

With some little fine adjustement to my code it WORKS!!

It is amazing! I love PIC!

Thank you for your help!
I will contact CCS with that problem.

here is the final code:
Code:
/*
http://www.ccsinfo.com/forum/viewtopic.php?t=42107
http://www.ccsinfo.com/forum/viewtopic.php?t=37024&highlight=mtouch
Built-in mTouch™ capacative sensing module

*/
#include <16lf722.h>

#fuses INTRC_IO,NOWDT,VCAP_A5
#use delay(INTERNAL=8Mhz)

#use rs232(baud=9600,rcv=PIN_C7,xmit=PIN_C6)
#use touchpad(scantime=32ms,threshold=6,PIN_B0='C',PIN_B1='5',PIN_B3='3')

#define GREEN_LED1   PIN_C2
#define GREEN_LED2   PIN_C3

//=========================

void main(void)
{
   char c;

   enable_interrupts(GLOBAL);

   output_high(GREEN_LED1);
   output_high(GREEN_LED2);
   delay_ms(300);
   output_low(GREEN_LED1);
   output_low(GREEN_LED2);

   while(1)
   {
      //   TOUCHPAD_STATE(1); //calibrates, then enters normal state
            if(touchpad_hit())
            {
               c=touchpad_getc();
               putc(c);
               
               if(c=='C')
                  output_toggle(GREEN_LED1);
   
               if(c=='5')
                  output_toggle(GREEN_LED2);
            }// end if
       
   } // end while
}// main
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