Hi,
I don't think the 12LF1822 allows you to "switch" timers for the CCP module, some do, this one seems not. As far as I can see it requires the use of TMR2 in PWM mode.
It looks to me like you should be able to use TMR0 for the timebase and TMR1 to do the "counting". Or why not use TMR1 to "count the pulses" and use your PWM timebase (TMR2) as the timebase for capacitive module as well? I have no idea what kind of periods we're talking about here but if the PWM period is too short to use as a timebase for the capacitive module you can use the TMR2 postscaler to divide that down further, tripping an interrupt every 1:2 - 1:16 cycle, meaning that with a PWM frequency of 20kHz you can get a timebase for the capsense as low 20k/16=1250Hz, is that too fast?
EDIT: Sorry, forgot that last question. Not sure what the actual limitations on HPWM are but you probably want to set up the CPP module "manually" instead of using HPWM. With 8MHz oscillator you can easily get 50kHz, the datasheet shows you all about how to calculate the values and I believe I've written a post or two about how it works (but how do I find that now...). I usuallt cheat though and use PICMultiCalc which, in this case tells me that with 8Mhz oscillator you'll get 50kHz by setting PR2 to 39. The dutycycle register then ranges from 0-160 for 0-100% dutycycle.
And again, at 50kHz PWM frequency and TMR2 postscaler of 1:16 you'll get an interrupt rate of ~3kHz. If that's too fast you can always do a little software postscaler as well. Or simply use TMR0 if you don't need it for anything else.
/Henrik.




Bookmarks