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).
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?
Set the WDT2 period to 3.9ms and use a "Global Signal Reference" component from system.
c) Don't I need to clear the WDTInt once I've serviced the ISR?
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?
Have a look into this document and see that you need to call CySysWdtClearInterrupt (uint32 counterMask) to avoid continuous calling of the interrupt handler.
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.
((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.