PSOC 4 BLE Set WDT interrupt priority

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

cross mob
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello,

   

I basically want to achieve the following behavior using WDT0 timer but in this moment I face 2 problems.

   

Use case: Start the WDT0 for about 10 ms (327 for match value); When expire, set a pin on 1 and start the WDT for about 0.28 ms ( 9 in match value). When this expire start ADC conversion, wait for result, start WTD0 for about 0.04ms (1 in match value). When this last time expires set the pin on 0. So basically at each 10 ms I want to create a signal on 1 for about 0.32 ms, like a clock but I want it to run also in deep sleep mode.

   

First problem is when set a match value < than 5 the CPU resets itself. I do not know why but with 5 in match value it is working but obvious the time is more than the 0.04ms wanted.

   

Second problem is caused by the interrupt priority as I expect because when run whitout any other component the 0.28 ms time is ~0.24ms and the adc conversion takes 10 uS as expected. On the other hand, when I run my application which includes other components like I2C, BLE, ADC, WDT1, etc; the time is about 0.89 ms (instead of 0.32 ms). I expect that the interrupts from I2C, BLE and others comes in and therefore delays the interrupt for WDT0. I do not need exact times, but close. So it is ok to have lets say 20-30 us delays but not 3 times the expected time.

   

Therefore my questions are: how to set the WDT0 interrupt to the highest priority to make my pulse? And, of course, why I cannot set a value les than 5 on math register?

   

Other details: Before  start first the WDT0 I set this:

   

/* Setup WDT Counter 0 to generate interrupt on match */
    CySysWdtWriteMode(CY_SYS_WDT_COUNTER0,CY_SYS_WDT_MODE_INT);
    /* associate a callback to wdt interrupt */
    CySysWdtSetInterruptCallback(CY_SYS_WDT_COUNTER0, WDTCompareMatchCallback);

   

Then When I start the WDT I do :

   

 /* Write match count */
    CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, XXX); // XXX 327, 9, 1
    /* Enable clear of counter on match */
    CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER0, 1u);
     /* Enable WDT counter 0 */
    CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK); 

   

Every time I reload a match value I do

   

/* Stop timer */
    CySysWdtDisable(CY_SYS_WDT_COUNTER0_MASK);

   

 

   

Thank you!

0 Likes
1 Solution
Anonymous
Not applicable

Hi Marian,

   

As you know, WDT is clocked by LFCLK. Is the LFCLK set to ILO or WCO in your design? WCO is more accurate. If you had set it to ILO, then there can be variations in actual WDT period.

   

Ideally, BLESS should be given the highest priority. You can set the interrupt priority under: interrupts tabs in .cydwr.

View solution in original post

0 Likes
9 Replies