PSOC4 BLE stop working when assign a WDT interrupt or a GPIO Interrupt

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 everybody,

   

I am currently working on a project that wants to get data from this sensor: http://wiki.seeedstudio.com/wiki/Grove_-_Dust_Sensor. In order to do this I need a timer that will elapses at 2 seconds and also works on DEEP SLEEP state and a GPIO interrupt set for Output pin of the sensor.

   

Therefore I did the following:

   

I took pin P1.6 and set it as High Impedance Digital(initial state 0) state Digital input and under the Input tab I set Interrupt to be Both Edges and dedicated interrupt was attach, configured and started with _StartEX(Handle) call.

   

For the Timer I chose WDT_Timer_0 since I need it to work also in deep sleep. I did not configure the timer inside creator but I used this code:

   

 <code>/* Setup WDT Counter 0 to generate interrupt on match */
    CySysWdtWriteMode(CY_SYS_WDT_COUNTER0,CY_SYS_WDT_MODE_INT);
    /* Write match count */
    CySysWdtWriteMatch(CY_SYS_WDT_COUNTER0, 65535);
    /* Enable clear of counter on match */
    CySysWdtWriteClearOnMatch(CY_SYS_WDT_COUNTER0, 1u);
    /* Enable WDT counter 0 */
    CySysWdtEnable(CY_SYS_WDT_COUNTER0_MASK);  

   

/* associate a callback to wdt interrupt */
    CySysWdtSetInterruptCallback(CY_SYS_WDT_COUNTER0, DUST_vProcessWDTTimerCallback);
   
   GrovePin_ISR_StartEx(GrovePinISR_Handler);

   

<code>

   

Some notes: It does not matter if I use this code or configure the timer inside creator, the interrupt gets fired every 2 seconds as intended!

   

I also use WDT_TIMER_2 for RTC and it is configured at 4 seconds(it works).Therefore I used the CySysWdtSetInterruptCallback call since in creator I need the auto generate mode for RTC. This is not the problem because the interrupt is fired and the callback attached is called.

   

The problem that I have is that when start the Interrupt on GPIO or set the Callback for WDT the entire code sometimes if I am not connected at BLE and always!! when connected to BLE, does not even reach the MAIN FOR loop. It will print the fact that it goes to GPIO interrupt and WDT 0 interrupt callbacks but it goes out of main code. The CySmart app disconnects the device and it needs a reset or else it will always commute in GPIO interrupt when the sensor pin goes 0 or 1, and in timer interrupt once at every 2 sec.

   

The code is complicated and uses many other sensors without a problem but when added this 2 callbacks it is dead.

   

My assumptions are: I did not set the GPIO state correctly(high impedance), using 2 WDT creates some confusion. Morover even if I set one of the 2 callbacks the code is broken.

   

If anyone has any idea it would be great. Thank you!

0 Likes
1 Solution

Hi Madhu,

   

I solved the problem with your advice. I set the priority for BLE at 0 and let the others to default and to be assign by the creator. Also it turns out the code could not get out from a ExitCriticalSection call and that was because of some UART sending calls. After some measurements we found that the UART calls somehow got in conflict with the WDT 0 callback call. Thanks for the fast response and if someone has such problems please check you amount of ISR calls in modules like UART module this my be also you cause.

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hi,

   

We need your code for review. Can you please create a Tech support case and attach a simplified version of the code where we can reproduce the issue?

   

Also, you can change the interrupt priorities in the *.cydwr file -> interrupt. Can you assign the highest priperity to BLESS?

   

Regards,

   

-Madhu Sudhan

0 Likes

Hi Madhu,

   

I solved the problem with your advice. I set the priority for BLE at 0 and let the others to default and to be assign by the creator. Also it turns out the code could not get out from a ExitCriticalSection call and that was because of some UART sending calls. After some measurements we found that the UART calls somehow got in conflict with the WDT 0 callback call. Thanks for the fast response and if someone has such problems please check you amount of ISR calls in modules like UART module this my be also you cause.

0 Likes