I'm wondering if we can tempt one of the experienced assembly guys here, to leverage on the "Automatic Context saving" interrupt capability aspect of these new line of PICs, which would place much less burden on the PIC when cap touch is used for switching.
All we need the associated assembly interrupt to do is this...
1. store the present timer1 count
2. setup a running count 'threshold' (by deducting x% from the last timer1 count)
3. compare present timer1 count with the 'threshold' .....if it is below, then a sensor has been touched, set a 'sensor touched' type flag, if the present timer1 count is not below the threshold, then store 'present timer1 count' away as 'last timer1 count' (for the next interrupt)
job done!
Else, if you have a lot of time sensitive stuff going on in your main loop, I fear you almost need to dedicate one pic (eg a 12f1822) solely to cap touch switching duties, due to the high frequency of interrupts needed & the chunky overhead they presently incur.




Bookmarks