4 Replies Latest reply on Mar 7, 2019 1:40 AM by frprc_1262176

    CY8C4024AZI-S413 Question about Capsense/ADC


      Hi all,


      in my application I use a CY8C4024AZI-S413 to read 5 CS buttons and 2 analog inputs.


      In this mcu, CapSense and ADC share the analog sensing block.


      The sampling frequency of at least one of the 2 analog signals could be up to 500 Hz and the sampling has a higher priority than the touch sensing.


      Is there any pitfall achieving that?



      For example, I could start a timer (period 2 ms) triggering the adc conversion.


      In this scenario, there could not be time to scan all the buttons.


      If that's the case, I could try to enable one button (each round) to limit the scan time.



      Do you see any particular drawback on the described approaches?



      Thanks for your time and help,


        • 1. Re: CY8C4024AZI-S413 Question about Capsense/ADC

          Hi frprc_1262176,


          Could you please provide more information on your request? Let us know the sequence of steps, when will you scan the sensors and when you will do the ADC conversion?


          The Capsense and ADC operation in controlled by the CSD sequencer and the ADC sequencer.  The ADC sequencer cannot be started unless the CSD sequencer has entered the normal sample state or is idle (ie after coarse and fine initialization of the sensors). You may have to take care of this.


          You can also refer to the below code example where they have used  Capsense and ADC together.






          • 2. Re: CY8C4024AZI-S413 Question about Capsense/ADC

            Hi BragadeeshV_41,


            sorry for the late response.


            Following is the example in pseudo-code of my approach.



            == TIMER 2 ms INTERRUPT HANDLER BEGIN ==


            if (CapSense_IsBusy())


                // should not be busy - previous sampling not terminated


                widgetIdx = (widgetIdx+1)%WIDGET_NUM;


                // other stuff


            CapSense_AdcStartConvert(0); // blocking conversion of adc channel 0


            CapSense_AdcStartConvert(1); // blocking conversion of adc channel 1



            CapSense_Scan(widgetIdx); // scan of single button (of index widgetIdx)


            == TIMER 2 ms INTERRUPT HANDLER END ==



            How can I achieve the scan of a single button thourhg the CapSense_ADC




            Thanks for your time.








            Il 27/02/2019 10:43 BragadeeshV_41 ha scritto:







            reply from BragadeeshV_41  in PSoC 4 MCU Community - View the

            full discussion


            • 3. Re: CY8C4024AZI-S413 Question about Capsense/ADC

              Hi user_377323744,


              Thanks for the update.


              I assume that you want to complete this entire process in 2 mS.


              If all those buttons are similar with respect to hardware settings, you could put all of them in one particular widget and perform a scan either using CapSense_SetupWidget(WidgetID) and CapSense_Scan() together or simply CapSense_ScanAllWidgets(). You can measure the approx time it takes for scanning using a timer. This method will scan faster.


              But if it is okay for your application to scan only sensor in every interrupt trigger, then you can connect each of the sensor to a separate widget and use CapSense_SetupWidget(WidgetID) and CapSense_Scan() together. You can vary the WidgetID to scan the other sensors.


              There is a third option to scan a particular sensor, (ie) CapSense_CSDSetupWidgetExt (uint32 widgetId, uint32 sensorId). This will connect the sensor to the AMUX bus, you need to call CapSense_CSDScanExt() to start the scanning process.


              Also, it is best practice to not have any application code in your ISR. Please implement something like below:





              flag = 1;





              if (flag)


              //Your application goes here




              Please let me know if anything wasn't clear.




              • 4. Re: CY8C4024AZI-S413 Question about Capsense/ADC

                Hi Bragadeesh,


                thanks for all the info. I'll close the thread.