Switch Low frequency clock (LFC) Source from ILO to WCO at Cyble022001-00

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

cross mob
Anonymous
Not applicable

Hello, I'm writing a program for BLE on the  Cyble022001-00

When using the WCO timer as clock source for LFC at startup a 500ms Wait is implemented in auto generated Code.

In this 500ms more than 70 percent of my application power is consumed due to the reset and the 500ms idle wait.

in order to solve this problem I decided to enable ILO and WCO and configure ILO as LFC source.

500ms after startup i want to switch from ILO to WCO as clock source and disable ILO totally.

Enabling BLE afterwards and handle Blue tooth communication.

After changing the clock source, i'm able to discover the BLE device, but no connection is possible.

Whenever I start with WCO as clock source everything works fine.

On other Code changes are made!

In order to switch clock source I used the AN95089 example.

any advice would be appreciated.

Thanks

my Code:

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

* Function Name: WDT_Start

********************************************************************************

*

* Summary:

*  Configures WDT to trigger an interrupt.

*

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

void WDT_Start(void)

{

    /* Unlock the WDT registers for modification */

    CySysWdtUnlock();

    /* Setup ISR */

    WDT_Interrupt_StartEx(&Timer_Interrupt);

    /* Write the mode to generate interrupt on match */

    CySysWdtWriteMode(WDT_COUNTER, CY_SYS_WDT_MODE_INT_RESET);

    /* Configure the WDT counter clear on a match setting */

    CySysWdtWriteClearOnMatch(WDT_COUNTER, WDT_COUNTER_ENABLE);

    /* Configure the WDT counter match comparison value */

    CySysWdtWriteMatch(WDT_COUNTER, WDT_TIMEOUT);

    /* Reset WDT counter */

    CySysWdtResetCounters(WDT_COUNTER);

    /* Enable the specified WDT counter */

    CySysWdtEnable(WDT_COUNTER_MASK);

    /* Lock out configuration changes to the Watchdog timer registers */

    CySysWdtLock();   

}

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

* Function Name: WDT_Stop

********************************************************************************

*

* Summary:

*  This API stops the WDT timer.

*

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

void WDT_Stop(void)

{

    /* Unlock the WDT registers for modification */

    CySysWdtUnlock();

    /* Disable the specified WDT counter */

    CySysWdtDisable(WDT_COUNTER_MASK);

    /* Locks out configuration changes to the Watchdog timer registers */

    CySysWdtLock();   

}

int main()

{

    /* Unfreeze IO-Cells */

    CySysPmUnfreezeIo();   

    WDT_Start();

       

   

    Wakeup_Interrupt_StartEx(&WakeupInt);

    CyGlobalIntEnable;

   

    if (CySysPmGetResetReason() == CY_PM_RESET_REASON_WAKEUP_HIB) {           

        //disableI2C(0u, 0);       

        WAKEUP_ClearInterrupt();

        Wakeup_Interrupt_ClearPending();

    }

  

    dbug1_Write(1u);

   

    while(1)

    {

        cycleCounter++;

       

        if ( u16WcoCycleCount == 0 && state == 0){ // wait 500ms realized with timer interrupt

          CyGlobalIntDisable;

          (void)CySysClkWcoSetPowerMode(CY_SYS_CLK_WCO_LPM);    /* Switch to the low power mode */

          CySysClkSetLfclkSource(CY_SYS_CLK_LFCLK_SRC_WCO);     /*Select WCO as the clock source*/

       

          /*Stop ILO*/

          CySysClkIloStop();

          WDT_Stop();

          WDT_Start();

          CyGlobalIntEnable;

          /* Stack Initialization */

          state = 1;

          CyBle_Start(AppCallBack);          

          //CyBle

        }

       

        /* CyBle_ProcessEvents() allows BLE stack to process pending events */

        CyBle_ProcessEvents();

}

0 Likes
7 Replies
Anonymous
Not applicable

When you say you can't connect:

Were you able to connect while using the WCO? (I'll assume yes based on your wording)

Is the ECO clock running? (I think it helps with timing, etc for the BLE)

Have you tried seeing if you can get away with removing the 500ms wait for the WCO startup? (probably breaks at a guess)

Did you configure your WCO for "Low Power" mode? If you place the BLE chip into sleep/deep sleep it will also reduce power usage when not actively communicating over the radio (There is more details to setting it up as it is involved, but the overall process will reduce current consumption).

Can you give the location of the 500 ms wait? (Being able to dig into it's source code would be useful for understanding)

0 Likes
Anonymous
Not applicable

Hello e.pratt.

Exactly if I use the WCO as Clock Source everything works as intended.

ECO is up and running.

As the 500ms are defined in auto generated code, no way to get rid of it by deleting.

File cyfitter_cfg.c

code:

static void ClockSetup(void)

{

    /* Set Flash Cycles based on max possible frequency in case a glitch occurs during ClockSetup(). */

    CY_SET_REG32((void CYXDATA *)(CYREG_CPUSS_FLASH_CTL), (0x0012u));

    /* Start the WCO */

    CySysClkWcoStart();

    CyDelayCycles(12000000u); /* WCO may take up to 500ms to start */

    (void)CySysClkWcoSetPowerMode(CY_SYS_CLK_WCO_LPM);    /* Switch to the low power mode */

........

As this is a simple delay, and performed before my main function is called I can do nothing to save power!

It seems like the controller stays in a kind of reset during that 500ms till WOC starts up, according to the power consumption I have monitored.

Thanks for your reply

0 Likes
Anonymous
Not applicable

As @Madhu_Lakshmipathy​ linked, the example project demonstrates turning down power settings while waiting for the WCO to stabilize. I must have run into the same issue with my project when I worked on it, but I guess I don't remember how I dealt with the 500ms delay on startup. My project doesn't restart much once running however, so that might be the solution I found...

0 Likes
Anonymous
Not applicable

Hi,

Use the below example project to drastically reduce the power consumption due to the 500 mS Startup time.

http://www.cypress.com/blog/100-projects-100-days/project-038-psoc-4-ble-low-power-startup

Regards,

- Madhu Sudhan

Anonymous
Not applicable

Hello and thanks for your answer, unfortunately it didn't work.

I have used the original example Project, and changed 2 settings.

1. Selected device is now CYBLE-022001-00 (the device I'm using)

2. BLE Setting changed from Broadcast/Observer to Profile.(as I need profiles in my application and you never connect to a Broadcast device)

Still get the same Error as described, every time I'll try to connect to the Cyble controller over BLE.

Seems like a general issue!

0 Likes
Anonymous
Not applicable

I went and tested the 022001-00 device I'm using, and it is showing the 500ms startup sequence same as you. My solution was to never reset unless I could help it

0 Likes
Anonymous
Not applicable

Hello e.pratt, thanks for your confirmation. Unfortunately we only need bluetooth every now and then, let's say once a week so, we use the Hibernate mode.

0 Likes