cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

Hello,

Iam using PSCO4 CYC4014 Microcontroller for our project,

Iam using below mentioned API's for detecting if finger press on button,

1) CapSense_CheckIsSensorActive()

2) CapSense_CheckIsWidgetActive()

Below is function snippet.

uint32 CapSense_CheckIsSensorActive(uint32 sensor)

{

    uint8 widget;

    uint8 debounce;

    uint8 debounceIndex;

    uint8 fingerThreshold;

    uint8 hysteresis;

   

    /* Prepare to find debounce counter index */

    widget = CapSense_widgetNumber[sensor];

    fingerThreshold = CapSense_fingerThreshold[widget];

    hysteresis = CapSense_hysteresis[widget];

   debounce = CapSense_debounce[widget];

        debounceIndex = widget;

    /* Was on */

    if (0u != CapSense_GetBitValue(CapSense_sensorOnMask, sensor))

    {

        /* Hysteresis minus */

        if (CapSense_sensorSignal[sensor] < (fingerThreshold - hysteresis))

        {

            CapSense_SetBitValue(CapSense_sensorOnMask, sensor, 0u);

            /* Sensor inactive - reset Debounce counter */

            CapSense_debounceCounter[debounceIndex] = debounce;

        }

    }

    else    /* Was off */

    {

        /* Hysteresis plus */

        if (CapSense_sensorSignal[sensor] >= (fingerThreshold + hysteresis))

        {

            CapSense_debounceCounter[debounceIndex]--;

            /* Sensor active, decrement debounce counter */

            if(CapSense_debounceCounter[debounceIndex] == 0u)

            {

                CapSense_SetBitValue(CapSense_sensorOnMask, sensor, 1u);

            }

        }

        else

        {

            /* Sensor inactive - reset Debounce counter */

            CapSense_debounceCounter[debounceIndex] = debounce;

        }

    }

    return ((uint32)((0u != CapSense_GetBitValue(CapSense_sensorOnMask, sensor)) ? 1u : 0u));

}

Iam not able to detect the finger press,Please let me know where the issue is.

Thanks & Regards,

Pramod

0 Likes
Reply
1 Solution
RyanZhao
Moderator
Moderator

Hi Pramod,

Yes. I think you could add I2C and debug and then add Timer and debug..to double-check where the issue is.

Recommend to run the code in debug mode and double-check when and why these paras becoming 0.

Thanks,

Ryan

View solution in original post

0 Likes
Reply
11 Replies
RyanZhao
Moderator
Moderator

Hi Pramod,

Could you share the full project?

uint32 CapSense_CheckIsSensorActive(uint32 sensor) is an internal function of CapSense v2.x.

Generally, it is recommended to use CapSense_CheckIsWidgetActive(Widget_Num) in main.c.

Thanks,

Ryan

0 Likes
Reply
Anonymous
Not applicable

Hi Ryan,

PFA Archive of the project,

Let me know where iam going wrong.

Thanks & Regards,

Pramod Kashyap

0 Likes
Reply
RyanZhao
Moderator
Moderator

Hi Pramod,

I got the project, I will have a debug in these several days and then come back to you with more details.

Before that, here are some suggestions FYI:

1. Use CapSense_CheckIsWidgetActive(0) to detect all sensors' status and then use CapSense_sensorOnMask[0] directly.

2. Modify all priority of ISRs as 3.

3. Create a simply debug project only with CapSense_CSD component to verify CapSense can work well.

Thanks,

Ryan

0 Likes
Reply
Anonymous
Not applicable

Hi ryan,

Thanks for Response,

I will try the API you have mentioned.

Please can you review the porject file ASAP.

As i need to fix this issue at the earliest.

Thanks,

Pramod

0 Likes
Reply
RyanZhao
Moderator
Moderator

Hi Pramod,

I bypassed Timer and I2C code, debugged CapSense and it works fine. Seems that debounce is about 9~10.

Capture.PNG

Thanks,

Ryan

0 Likes
Reply
Anonymous
Not applicable

Hi ryan,

Thanks for checking with project.

Actually i require both I2C and timer in our project along capsense module.

Iam observing that after 20 sec running the code,Finger threshold,Hysteresis and debounce parameter value are becoming 0.

Can you please help me on this issue.

Thanks,

Pramod

0 Likes
Reply
RyanZhao
Moderator
Moderator

Hi Pramod,

Yes. I think you could add I2C and debug and then add Timer and debug..to double-check where the issue is.

Recommend to run the code in debug mode and double-check when and why these paras becoming 0.

Thanks,

Ryan

View solution in original post

0 Likes
Reply
Anonymous
Not applicable

Hi Ryan,

I will check and debug as you have said.

Thanks,

Pramod Kashyap

0 Likes
Reply
Anonymous
Not applicable

Hi ryan,

After bypassing I2C and debugging the issue seems to be resolved.

Can you please let me know why this issue is coming up.

I have given all the ISR priority at the same level.

Thanks & Regards,

Pramod Kashyap

0 Likes
Reply
Anonymous
Not applicable

Hi ryan,

Why all priority of ISR to be set to 3.

Please can you elabrote on this.

Thanks.

Pramod

0 Likes
Reply
RyanZhao
Moderator
Moderator

Hi Pramod,

Sure.

Regarding of the priority of ISR. If not same, high level ISR may interrupt low level interrupt's handler task. This should be avoided if some resources shared by different component, such as shared GPIO port. If nested interrupt is required, be careful to double-check in case of any risk.

Thanks,

Ryan

0 Likes
Reply