View previous topic :: View next topic |
Author |
Message |
GiG
Joined: 03 Sep 2021 Posts: 39
|
use timer 2 in csm module |
Posted: Tue Mar 15, 2022 7:08 am |
|
|
Hi everyone
I had a question about the built-in touch sensor module,csm
it's my first time that i use this module
I use micro pic16f723a
And I use timer zero to control delays and timer one to set up the remote control and I did not use timer two
I wanted to read the 4 inputs of spring touch using the internal sensor of the micro, but I was a little confused by reading the data sheet.
I do not know if this module only works with one timer or two timers now.
Can I transfer this module's timer in CCS to only timer 2 that i did't use?
if yes how?
Thank you for your help |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Tue Mar 15, 2022 9:14 am |
|
|
Normally capacitive sensing uses one timer for the timing, and one for
the interval between. The second can be re-used by your own code,
by setting the interval to the value you want, and simply adding your
own handler for this interrupt. The two handlers get called one after
the other. The #use sets this timer up (so don't change the settings
for this timer in your code).
So, let timer0 go free. If the interval can be the same as your delay
function, use timer1 for this, and then use timer2 for your remote control. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9224 Location: Greensville,Ontario
|
|
Posted: Tue Mar 15, 2022 9:19 am |
|
|
I looked at the datasheet, CSM chapter, diagram.
While timer2 can be used as a 'gate', it can't be used as the actual 'timing' element.
There may be a way to use timer0 and timer 1 for all your functions, if you can use the interrupts from them though. |
|
|
GiG
Joined: 03 Sep 2021 Posts: 39
|
|
Posted: Wed Mar 16, 2022 2:38 am |
|
|
Thank you Ttelmah
temtronic
I clearly did not understand what you mean. Can you explain a little more?
Thanks
look at me as a beginner |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Wed Mar 16, 2022 4:39 am |
|
|
Jay was suspicious that your remote control and timings might all be doable
on just one interrupt. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9224 Location: Greensville,Ontario
|
|
Posted: Wed Mar 16, 2022 6:10 am |
|
|
Have a look at this...
http://www.ccsinfo.com/forum/viewtopic.php?t=26177
See what happens in the actual ISR.
It's a timer based Real Time Clock that uses one timer interrupt to update several variable ( second,minutes, hours )
You could do a similar interrupt, where you increment several 'flags'. Then in main(), you do 'something' based upon what those 'flags' are. |
|
|
|