Announcements

Curious on how you can apply PSoC™ 6 to Smart Home Appliances? Register for the ASEAN Smart Home Appliance Webinar here to find out how.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

inja_4756821
Level 1
First like received First solution authored 5 replies posted
Level 1

Dear Experts.

 

Using CY8CKIT-062-WiFi-BT (PsoC6 WiFi-BT Pioneer Kit), i'm testing to use CSD Capsense & CSDADC functions at the same time.
CAPSENSE™ Middleware Library 3.0: High-level Functions (infineon.github.io)

With reference to the above, I am testing by switching Capsese and CSDADC.
I checked the mode conversion and CSDADC was read normally.

However, CapSense does not work properly.
I'm try to fix everything, it doesn't work.

Please help if there are any mistakes or areas that need to be corrected.

***

This is a project created by adding CSDADC and SARADC to the CAPSENSE_Buttons_and_Slider example.

(File Attached)

CSDADC: P1_2, P1_3, P1_4
SARADC: P10_0, P10_1, P10_4, P10_5
CAPSENSE: BTN: P8_1, P8_2,
Slider : P8_3~7

thank you

0 Likes
1 Solution
Vison_Zhang
Moderator
Moderator 10 likes given 500 replies posted 100 sign-ins
Moderator

Cy_CapSense_ScanAllWidgets()  API is a non-blocking function, it only trigger sensors to prepare & start scanning process but do not wait for sensor to finished the scan. So in your original code,  Cy_CapSense_Save() and Cy_CSDADC_Restore() will execute before sensor finished the scan, this broken the config of CSD mode.   My code check the isbusy status of CSD block to realize blocking which prevent CSD config switch to other mode before sensor is scan & process completely.

 You add cyhal_system_delay_ms(CSDADC_CONVERSION_DELAY_MS) to make sure CSDADC mode won't be change back to CSD mode, that's why  CSDADC works. But you should care the same issue for CSD mode.

Change the drive code of CapSense mode to below can fix the issue.

/***********************************************************************/

//******************* for CAPSENSE Mode *************************
Cy_CapSense_Restore(&cy_capsense_context);

sysint_status = Cy_SysInt_Init(&capSense_intr_config, &capsense_isr);
check_status("Interrupt initialization failed", sysint_status);

/* Initiate first scan */
Cy_CapSense_ScanAllWidgets(&cy_capsense_context);

/* wait until scan finished */

while(CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(&cy_capsense_context));


Cy_CapSense_ProcessAllWidgets(&cy_capsense_context);

/* Process touch input */
process_touch();
#if(CAPSENSE_TUNER_ENABLE)
Cy_CapSense_RunTuner(&cy_capsense_context);
#endif

#if 0
if (capsense_scan_complete)
{
printf("capsense_scan_complete123\r\n\r\n");
/* Process all widgets */
Cy_CapSense_ProcessAllWidgets(&cy_capsense_context);

/* Process touch input */
process_touch();

Cy_CapSense_RunTuner(&cy_capsense_context);
/* Initiate next scan */
Cy_CapSense_ScanAllWidgets(&cy_capsense_context);

capsense_scan_complete = false;
}
#endif

Cy_CapSense_Save(&cy_capsense_context);

/***********************************************************************/

 

View solution in original post

4 Replies
Srivastav
Moderator
Moderator 5 likes given 50 replies posted 25 solutions authored
Moderator

Hi inja_4756821

thank you for reaching out to us.

Please explain "CapSense Doesn't work Properly"

Is it getting Initialized or not? or Is it related to Manual Tuning? Are you able to open ModusToolbox Tuner and observe the change in Rawcounts under touch condition? Please explain.

Thank You
Kind Regards

Arpit Srivastav

 

0 Likes
inja_4756821
Level 1
First like received First solution authored 5 replies posted
Level 1

Hi Arpit.

Thank you for reply.

I used the built-in Capsense SDK project. Each mode of CSDADC and capsense works well.
However, when I use Capsense and csdadc through periodic mode switching, the buttons and sliders in Capsense don't work. ( capsense_save & restore / csdasdc_save & restore API)
only CSDADC works normally.

(Each function works fine independently, but when using CAPSENSE and CSDADC via mode change CAPSENSE does not work as expected.)

refer to above request & attached file.

Thank you

0 Likes
inja_4756821
Level 1
First like received First solution authored 5 replies posted
Level 1

Dear Arpit.

I've solved that issue.

The operation was tested based on RTOS, and there is no problem even if the Capsense operates at a cycle of 10ms, but it seems that a delay time is required when changing the mode with CSDADC. If it operates in units of 1000ms, there seems to be no problem so far.

0 Likes
Vison_Zhang
Moderator
Moderator 10 likes given 500 replies posted 100 sign-ins
Moderator

Cy_CapSense_ScanAllWidgets()  API is a non-blocking function, it only trigger sensors to prepare & start scanning process but do not wait for sensor to finished the scan. So in your original code,  Cy_CapSense_Save() and Cy_CSDADC_Restore() will execute before sensor finished the scan, this broken the config of CSD mode.   My code check the isbusy status of CSD block to realize blocking which prevent CSD config switch to other mode before sensor is scan & process completely.

 You add cyhal_system_delay_ms(CSDADC_CONVERSION_DELAY_MS) to make sure CSDADC mode won't be change back to CSD mode, that's why  CSDADC works. But you should care the same issue for CSD mode.

Change the drive code of CapSense mode to below can fix the issue.

/***********************************************************************/

//******************* for CAPSENSE Mode *************************
Cy_CapSense_Restore(&cy_capsense_context);

sysint_status = Cy_SysInt_Init(&capSense_intr_config, &capsense_isr);
check_status("Interrupt initialization failed", sysint_status);

/* Initiate first scan */
Cy_CapSense_ScanAllWidgets(&cy_capsense_context);

/* wait until scan finished */

while(CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(&cy_capsense_context));


Cy_CapSense_ProcessAllWidgets(&cy_capsense_context);

/* Process touch input */
process_touch();
#if(CAPSENSE_TUNER_ENABLE)
Cy_CapSense_RunTuner(&cy_capsense_context);
#endif

#if 0
if (capsense_scan_complete)
{
printf("capsense_scan_complete123\r\n\r\n");
/* Process all widgets */
Cy_CapSense_ProcessAllWidgets(&cy_capsense_context);

/* Process touch input */
process_touch();

Cy_CapSense_RunTuner(&cy_capsense_context);
/* Initiate next scan */
Cy_CapSense_ScanAllWidgets(&cy_capsense_context);

capsense_scan_complete = false;
}
#endif

Cy_CapSense_Save(&cy_capsense_context);

/***********************************************************************/