View previous topic :: View next topic |
Author |
Message |
JerryR
Joined: 07 Feb 2008 Posts: 167
|
touchpad resources |
Posted: Fri Aug 30, 2019 8:03 pm |
|
|
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
|
|
Posted: Fri Aug 30, 2019 8:47 pm |
|
|
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
|
|
Posted: Sat Aug 31, 2019 5:17 pm |
|
|
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
|
|
Posted: Sat Aug 31, 2019 11:26 pm |
|
|
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
|
|
Posted: Sun Sep 01, 2019 7:15 am |
|
|
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
|
|
Posted: Sun Sep 01, 2019 11:08 am |
|
|
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'. |
|
|
|