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

touchpad resources

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



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

touchpad resources
PostPosted: Fri Aug 30, 2019 8:03 pm     Reply with quote

I'm working on code for the PIC16F1933 target. I'm noticing conflicts between using timer interrupts for scheduling when using touchpad routines. What timer resources are used when using touchpad routines? Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 30, 2019 8:47 pm     Reply with quote

The CCS manual says:
Quote:

#use touchpad()

Description:
This directive will tell the compiler to initialize and activate
the Capacitive Sensing Module (CSM)or Charge Time
Measurement Unit (CTMU) on the microcontroller. The compiler
requires use of the TIMER0 and TIMER1 modules for CSM
and Timer1 and ADC modules for CTMU, and global
interrupts must still be activated in the main program in order
for the CSM or CTMU to begin normal operation. For most
applications, a higher RANGE, lower THRESHOLD, and higher
SCANTIME will result better key press detection. Multiple PINs
may be declared in "options", but they must be valid pins used
by the CSM or CTMU. The user may also generate a TIMER0 ISR
with TIMER0's interrupt occuring every SCANTIME milliseconds.
In this case, the CSM's or CTMU's ISR will be executed first.
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

PostPosted: Sat Aug 31, 2019 5:17 pm     Reply with quote

PCM:

Thanks for your reply. I'll be back in the lab on Monday and change some timers around and retest. Regards.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Sat Aug 31, 2019 11:26 pm     Reply with quote

What's perhaps also worth studying and understanding is the comment
about still being able to have your own interrupt handler for timer0.
What happens is if you generate a timer0 ISR, this will be called as
normal, but after the touchpad code. The touchpad code will change
the timer count to ensure that the interrupt occurs at pretty close to the
scantime interval (it won't be exact, but very close). So your routine must
not change the timer value, and the interval will be controlled 'for you' at
the specified scantime.
So if you wanted a timer0 at a particular interval, the solution is to simply
set the touchpad scantime to the interval required.
JerryR



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

PostPosted: Sun Sep 01, 2019 7:15 am     Reply with quote

Ttelmah, yes understand. However, I'm not using timer0 and leaving it untouched and allowing touchpad to use it as it requires. I'm currently using timer4 int to schedule other tasks.

Thanks so much for the group's guidance. Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Sun Sep 01, 2019 11:08 am     Reply with quote

Good.

However two things:

First on a lot of chips there are not that many timers, so saving one may
matter.
Second though is overhead. Every interrupt being serviced brings the
overhead of having to save the registers and restore them. If you add a
second handler to the timer 0 interrupt with the touchpad routines, there
is only a single overhead. The compiler saves the registers, calls it's
own handler, then calls your handler, and then restores the registers. A
major saving in the overhead involved.

Worth 'being aware'.
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