9 Replies Latest reply on Nov 9, 2016 3:08 AM by user_1377889

    Capsense interrupt

    user_419482461

       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

        • 1. Re: Capsense interrupt
          user_1377889

          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

          • 2. Re: Capsense interrupt
            user_419482461

             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

            • 3. Re: Capsense interrupt
              user_1377889

              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

              • 4. Re: Capsense interrupt
                user_419482461

                 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

                • 5. Re: Capsense interrupt
                  user_385543602

                   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

                  • 6. Re: Capsense interrupt
                    user_14586677

                    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.

                    • 7. Re: Capsense interrupt
                      user_1377889

                      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

                      • 8. Re: Capsense interrupt
                        neuhauser.johann_1862776

                        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

                        • 9. Re: Capsense interrupt
                          user_1377889

                          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