CYBLE-222014-01 Use 32 kHz WCO as Clock source for TCPWM_1

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

cross mob
TeMa_1467596
Level 5
Level 5
5 sign-ins 5 likes given First like received

I have a project running on a CYBLE-222014-01 module which uses TCPWM_1 as a counter that is driven by a 32 kHz clock (derived from 48 MHz HFClk).  TCPWM_1 drives an ISR that triggers 250 times per second.

Now I'm trying to reduce power consumption and wanted to set things up so that I can DeepSleep between every ISR_1 trigger but I realize that I need to use a 32 kHz clock source that runs while in DeepSleep which I think has to be the WCO (which I am pretty sure is implemented on the CYBLE-222014-01 module).  Am I on the right track?

One issue is that I can't seem to select the WCO as the clock source for TCPWM_1, if I try to use the LFClk, it gives me an error (see picture).

TCPWM_1.png

I've searched the forum and it looks like I may need to use a WDT in place of TCPWM_1 but I'm unclear on how this will work; how can I make the WDT generate an ISR or (ideally) hook it up to dtrigger my existing ISR_1 at the rate of 250 times per second?

Thanks in advance.

Ted

0 Likes
1 Solution

Thanks, I set that up but I am now looking for confirmation that I need to:

a) Move the code from my ISR_1 to ISR_2

b) Makes sure the actions I take reflect a 256 times per second call rather than a 250 times per second

c) Don't I need to clear the WDTInt once I've serviced the ISR?

The picture shows my added GlobalSignal_2 (don't know why it's 2 as I don't have one already AFAIK) and my now disabled TCPWM_1 and ISR_1 where all my code is right now

GT2.PNG

View solution in original post

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Set the WDT2 period to 3.9ms and use a "Global Signal Reference" component from system.

Bob

EDIT: Period corrected

0 Likes
Anonymous
Not applicable

user_1377889 WDT period of 4ms would give 250 Hz, not 250 ms. From what I can see in the IDE, it looks like you won't be able to wire the LFCLK or the WDT interrupt to the TCPWM_1. But, you can do an ISR with the WDT:

WDT_ISR.PNG

0 Likes

Thanks, I set that up but I am now looking for confirmation that I need to:

a) Move the code from my ISR_1 to ISR_2

b) Makes sure the actions I take reflect a 256 times per second call rather than a 250 times per second

c) Don't I need to clear the WDTInt once I've serviced the ISR?

The picture shows my added GlobalSignal_2 (don't know why it's 2 as I don't have one already AFAIK) and my now disabled TCPWM_1 and ISR_1 where all my code is right now

GT2.PNG

0 Likes

Well I created and compiled but, as I suspected, my code gets stuck, in the ISR I presume because, as soon as I power up, ISR_2 is triggered and I haven't figured out what the command is to disable the ISR call flag.  I've attached a picture of my LF Clock setup, any help appreciated.

P.S. Is it OK that I disabled the ILO?  My plan is that the HF Osc will drive the device when not asleep and the WCO will run always.  When I put teh device into DeepSleep, the WCO will continue to run and the ISR will wake the device up - does that sound sensible?

WDT2.png

0 Likes

Have a look into this document and see that you need to call CySysWdtClearInterrupt (uint32  counterMask) to avoid continuous calling of the interrupt handler.

Bob

Guys,

Thanks for your help, that last command was what was missing.  Because I used Timer2(WDT2), the command that worked was...

    CySysWdtClearInterrupt(CY_SYS_WDT_COUNTER2_INT);

Now I have to alter my code to handle 256 instead of 250 calls per second - actually I think I can drop that down to maybe 25 and still achieve all that I did before.

0 Likes
Anonymous
Not applicable

a) Move the code from my ISR_1 to ISR_2

b) Makes sure the actions I take reflect a 256 times per second call rather than a 250 times per second

c) Don't I need to clear the WDTInt once I've serviced the ISR?

a) Isr_2 is where you should have your interrupt code handling (seems like you figured that out already

b) To change the actions per second, try using the following math:

((WDT Clock)/(WDT Period)) = # of times per second the WDT ISR will fire.

Thus, to get 256 Hz, set the clock value in the calculation to 32,000 and divide by 256 to get the approximate period of the WDT that you need for 256 Hz: 32,000/256 = 125 for the period of the WDT at 32kHz to fire 256 times per second.

c)  I would suggest clearing the interrupt as soon as you enter the ISR to reduce the possibility of missing an ISR trigger;

0 Likes