- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am working on the Pioneer Kit PSoc4 and I want to know little more about capsense. I configered 5 buttons.
Is there another way to detect if one from the buttons is pressed than the CapSense_CheckIsWidgetActive(CapSense_BUTTON0__BTN) command?
For example to put them in a array that it is possible to read them with a for next loop. Now I have to put 5 if then loops to check every button separately.
How do I generate a interrupt when one from the buttons is pressed. Or how can I use the Capsense_INT.c to handle all pressed buttons?
For example I worked with the ADC_INT.c this worked very fine. Also other interrupt are working as expected. Except the Capsense isn't working like expected.
My Goal is to get the Capsense code out the MAIN.c and to put it in a ISR what only runs when a button is pressed. In this ISR i want only a few lines to buffer the pressed key.
Thanks in advance,
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Bob,
I did make a timer that generates every 25 ms an interrupt. The CDS can't handle faster. In the ISR I set an array with the status from each button. In my main I only pol the status from my array. This works for me.
Thanks for the fast answer,
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Bob,
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.
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am having trouble getting CapSense to work inside an interrupt unless I comment out:
// Wait for scanning
while(CapSense_IsBusy());
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.
Thank you,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
period.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?