- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Francesco
Solved! Go to Solution.
- Labels:
-
PSoC 4 Architecture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
TimerISR()
{
ClearInterrupt();
flag = 1;
}
main()
{
if (flag)
{
//Your application goes here
}
}
Please let me know if anything wasn't clear.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi user_377323744,
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.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
while(CapSense_AdcIsBusy());
CapSense_AdcStartConvert(1); // blocking conversion of adc channel 1
while(CapSense_AdcIsBusy());
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
API?
Thanks for your time.
Regards,
FP
Il 27/02/2019 10:43 BragadeeshV_41 ha scritto:
CYPRESS DEVELOPER COMMUNITY
CY8C4024AZI-S413 QUESTION ABOUT CAPSENSE/ADC
reply from BragadeeshV_41 in PSoC 4 MCU Community - View the
full discussion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
TimerISR()
{
ClearInterrupt();
flag = 1;
}
main()
{
if (flag)
{
//Your application goes here
}
}
Please let me know if anything wasn't clear.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh,
thanks for all the info. I'll close the thread.
Regards,
FP