9 Replies Latest reply on Jan 10, 2017 1:43 AM by himam_31

    PSOC 4 BLE Set WDT interrupt priority




      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 */
          /* 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 */


      Every time I reload a match value I do


      /* Stop timer */




      Thank you!