Welcome in the forum, Frank!°
Afaik is the capsense interrupt used for internal handlins and I am afraid that touching it might have influence on the performance. There are different approaches, but you have to keep in mind the requred timing. Reading CapSense 5 buttons takes some ms, proximity switches even longer. So you may use a timer and its interrupt to scan all your CSD-components and set a flag which can be polled in the main-loop. There is an interrupt within a M0 core that will not be used by Cypress components. It is not quite easy to use, but you can. Get hands on the "Cortex M0 Generic User's Guide" from ARM describing the core CPU in depth.
Fine that I could be of some help.
I have red somewhere that the user of a device expects a response to an action within 200 to 300 ms or it feels like "delayed". That would give you some more time and thus freeing some more precious MIPS when you set your timer to 100 ms.
I set it to 250ms, and yes otherwise it will slow down the complete sytem. It makes no sense to set it faster because its not common to hit 4 buttons a second. Thanks for the tip.
I am having trouble getting CapSense to work inside an interrupt unless I comment out:
// Wait for scanning
If I comment it out, it works fine. To those in this post who have this working (and anyone else), are you waiting for CapSense? I have tried the timer at 100 and 250ms.
Just a thought but generally speaking do not wait inside a ISR, or
for that matter create any blocking like f() calls,etc. Rather use a flag
inside ISR and process outside. You tie up the CPU if the wait f() is
blocking, and if it is not you would wind up with an imprecise wait
Some more information concerning interrupts: While an interrupt is handled, all other interrupts of lower and same priority are getting postponed (this is what the priorities are good for) until the handler returns from interrupt.
This additionally shows why Dana's advice to keep handlers short and fast is more than good programming-style,
can anyone tell me when the internal CapSense interrrupt occurs?
I need this information to design my low power application... My approach is to put the Cpu to Sleep while CapSense is busy and would be woken up by this interrrupt.
If the interrupt occurs when CapSense read is completed, this would be perfect.
Thanks in advance
You do not need to use the interrupt. When going to sleep, the CPU will be woken up by any interrupt. Check for CapSense_IsBusy() and if so, go to sleep again. Nonetheless: there is a macro callback defined "CapSense_ISR_EXIT_CALLBACK". See Creator help on how to use macro callbacks.
Hi all, JoMe_264151 you mentioned "So you may use a timer and its interrupt to scan all your CSD-components and set a flag which can be polled in the main-loop." I want to basically do the same as the above post - remove the capsense button (i have 1) and put it into an interrupt just like a mechanical button - "when button is pressed do this" - in my case iterate the mode of the device at any time whilst running my code on the device. Im new to PSOC and cant find any sample code anywhere which seems crazy as I'm sure this is a common thing.
To re-itterate when the capsense signal is "seen" itterate the mode whilst I'm running my code in the for loop of the main program.
can anyone help with sample code for this?