Enabling MCWDT with WCO

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

cross mob
user_4631386
Level 1
Level 1
First question asked First reply posted

I've been struggling with enabling the MCWDT with WCO, and I'm thinking that I've missed something obvious.

I'm using a custom board with a CYBLE-416045-02 module (Cypress PSoC 63 BLE).

I've set up the WCO in Modus Toolbox 2 configuration tool with default configuration. But when the WCO is enabled, the initialization halts when waiting for the WCO_OK bit to go high.

I've tried to call the PDL functions myself, with the same result. After enabling WCO the OK bit never goes high.

I have a similar issue with the MCWDT which might/might not be related. I'm setting counter 0 to interrupt mode and clear on match. The configuration parameters are set in the Configuration tool. After enabling the MCWDT I've tried to read the enabled status, and it is disabled. Even after several ms. I'm guessing this is also a bit in the register that doesn't go high.

So I'm thinking that something else needs to be enabled? Hope someone has a clues of what is going on.

I have tested it on multiple board, with the same result.

Code for setting up the MCWDT (in case it could be relevant):

cy_stc_sysint_t sensorTimerInterruptConfig = {

    .intrSrc = (IRQn_Type) INTERRUPT_TIMER_IRQ,

    .intrPriority = 5u

};

static void sensorTimerISR(void)

{

// Some code

}

Cy_MCWDT_Init(INTERRUPT_TIMER_HW, &INTERRUPT_TIMER_config);

Cy_SysInt_Init(&sensorTimerInterruptConfig, sensorTimerISR);

NVIC_EnableIRQ((IRQn_Type)sensorTimerInterruptConfig.intrSrc);

Cy_MCWDT_Enable(INTERRUPT_TIMER_HW, CY_MCWDT_CTR0, 93);

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

We have a blog which explains how to use MCWDT in ModusToolbox which you might find useful: https://iotexpert.com/2020/04/06/psoc-6-using-the-mcwdt-as-a-deep-sleep-timer/

If this doesn't help, please attach your project and we will have a look.

Regards,

Dheeraj

View solution in original post

2 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

We have a blog which explains how to use MCWDT in ModusToolbox which you might find useful: https://iotexpert.com/2020/04/06/psoc-6-using-the-mcwdt-as-a-deep-sleep-timer/

If this doesn't help, please attach your project and we will have a look.

Regards,

Dheeraj

Thank you, the article helped me fix the issue with the MCWDT. The interrupt is now working.

I still have issues with the WCO however.

I have created a new empty project and added the code from the article - minus the LED. This works fine. Then I enable the WCO in the configurator, and the initialization causes an error when waiting for WCO_OK bit to go high. Is it correct that a crystal is already included in the CYBLE-416045-02 module? So it should be possible to enable the WCO "out-of-the-box"? Otherwise it could be an issue with our custom board that we have to fix.

This is the sample code I'm using in the test-project:

#include "cybsp.h"

#include "cyhal.h"

#include <stdio.h>

void mcwdtISR()

{

     Cy_MCWDT_ClearInterrupt (mycounter_HW,CY_MCWDT_CTR1);

     //cyhal_gpio_toggle(CYBSP_USER_LED1);

}

int main(void)

{

     cybsp_init() ;

     //cyhal_gpio_init(CYBSP_USER_LED1,CYHAL_GPIO_DIR_OUTPUT,CYHAL_GPIO_DRIVE_STRONG,1);

     cy_stc_sysint_t intrCfg =

     {

          .intrSrc = mycounter_IRQ,

          .intrPriority = 4UL

     };

     Cy_SysInt_Init(&intrCfg, mcwdtISR);

     NVIC_EnableIRQ(mycounter_IRQ);

     __enable_irq();

     Cy_MCWDT_Unlock(mycounter_HW);

     Cy_MCWDT_Disable(mycounter_HW, CY_MCWDT_CTR0 | CY_MCWDT_CTR1, 100);

     Cy_MCWDT_Init(mycounter_HW,&mycounter_config);

     Cy_MCWDT_SetInterruptMask( MCWDT_STRUCT0, CY_MCWDT_CTR1 );

     Cy_MCWDT_Enable(mycounter_HW, CY_MCWDT_CTR0 | CY_MCWDT_CTR1 , 100);

     for(;;)

     {

          Cy_SysPm_DeepSleep(CY_SYSPM_WAIT_FOR_INTERRUPT);

     }

}

0 Likes