cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

Anonymous
Not applicable

Hello, after a few tries with example Codes, I wanted try a "full custom" program.

I'm using Evalkit PSoC4000S with 4045 Controller.

Now I have added and configured incl. Pin's a Capsense and a EZI2C component.

First I only want test/detect one Button (CSD) with the Launch Tuner.

Now I think I have problem with the main.c implementation. Respectively I have difficult to understand all the function with correct order, position and which one has to be to use. Please find below my first Code. After starting the Tuner I cannot detect any Signal:

#include "project.h"

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

   

    /* Start EZI2C block */

    EZI2C_Start();

   

     /* Set up communication data buffer to CapSense data structure to

     * expose to I2C master at primary slave address request       

     */

    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),\

                         (uint8 *)&CapSense_dsRam);

   

     /* Start CapSense block - Initializes CapSense data structure and

     * performs first scan of all widgets/sensors to set up sensors

     * baselines

     */

    CapSense_Start();

    CapSense_ScanAllWidgets();

    CapSense_RunTuner();

   

    for(;;)

    {

        if((CapSense_NOT_BUSY == CapSense_IsBusy()))

        {

           

                                #if (TUNER_UPDATE_ENABLE)

                                if(CapSense_STATUS_RESTART_DONE == CapSense_RunTuner())

                                {

                                   /* Set up sensor */

                                CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID)

                                 }

                                #endif

                               

                CapSense_CSDSetupWidgetExt(CapSense_BUTTON0_WDGT_ID, CapSense_BUTTON0_SNS0_ID);

                CapSense_CSDScanExt();

               

               

        }

    }

}

/* [] END OF FILE */

thank you very much

0 Likes
1 Solution
RyanZhao
Moderator
Moderator

Hi Pierre,

In the for loop, the required code should be:

"

Scan sensors;

Wait for scan completed;

Process scan data;

"

It lacks 'processing scan data' in your code.

Here is a simply example:

"

int main()

{    

    /* Enable global interrupts. */

    CyGlobalIntEnable;   

       

    /* Set up communication data buffer to CapSense data structure to

    *  expose to I2C master at primary slave address request

    */

    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),\

                                (uint8 *)&CapSense_dsRam);

   

    /* Initialize I2C component for CapSense tuner */

    EZI2C_Start();

   

    /* Initialize the CapSense CSD block */

    CapSense_Start();

    CapSense_ScanAllWidgets();

    while(CapSense_IsBusy()){}

    CapSense_InitializeAllBaselines();

    /* The main for loop */

    for(;;)

    {  

        /* Scan */   

        CapSense_ScanAllWidgets();

       

        /* Wait until scan complete */

        while(CapSense_IsBusy()){}

        /* Process */

        CapSense_ProcessAllWidgets();

        /* Run Tuner */       

        CapSense_RunTuner();

    }

}

"

To run tuner smoothly, remember to set sub-address size(bits) of EzI2C as 16.

You can also refer code example in the component datasheet.

Thanks,

Ryan

View solution in original post

1 Reply
RyanZhao
Moderator
Moderator

Hi Pierre,

In the for loop, the required code should be:

"

Scan sensors;

Wait for scan completed;

Process scan data;

"

It lacks 'processing scan data' in your code.

Here is a simply example:

"

int main()

{    

    /* Enable global interrupts. */

    CyGlobalIntEnable;   

       

    /* Set up communication data buffer to CapSense data structure to

    *  expose to I2C master at primary slave address request

    */

    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),\

                                (uint8 *)&CapSense_dsRam);

   

    /* Initialize I2C component for CapSense tuner */

    EZI2C_Start();

   

    /* Initialize the CapSense CSD block */

    CapSense_Start();

    CapSense_ScanAllWidgets();

    while(CapSense_IsBusy()){}

    CapSense_InitializeAllBaselines();

    /* The main for loop */

    for(;;)

    {  

        /* Scan */   

        CapSense_ScanAllWidgets();

       

        /* Wait until scan complete */

        while(CapSense_IsBusy()){}

        /* Process */

        CapSense_ProcessAllWidgets();

        /* Run Tuner */       

        CapSense_RunTuner();

    }

}

"

To run tuner smoothly, remember to set sub-address size(bits) of EzI2C as 16.

You can also refer code example in the component datasheet.

Thanks,

Ryan

View solution in original post