1 Reply Latest reply on Aug 21, 2019 8:45 AM by DheerajK_81

    PSoC 4 Pioneer Kit: Debug vs Release: Timer not working in release mode

    SiSc_4153271

      Hey,

       

      I'm using the Eddystone Project from the "100_Project_in_100_Days" Example:

      PSoC-4-BLE/100_Projects_in_100_Days/Project050_Eddystone at master · cypresssemiconductorco/PSoC-4-BLE · GitHub

       

      I added some code to be able to read data from the Pioneer Kit.

      I've set up an interrupt for a button press to send the amount of button presses to the app(this works fine). After that I wanted to set up a Timer to send the time in seconds to my App. Unfortunately the sending of the time is not working in release mode. It's only working in debug mode. I already read other topics in this forum like Debug vs. Release  and therefore I changed the values to volatile but this did't fix my problem.

       

      If some of you guys want to reproduce this problem. Just download the Beacon Scanner – Apps bei Google Play  and program the code to a PSoC 4 Pioneer Kit.

      If you press the switch SW2 on the Pioneer Kit you should see an increasing value of "packet sent" in the app. If you run the app in debug mode you should see an increasing value at the "Uptime .... seconds" in the app. But! If you run the app in release mode, the uptime value is not increasing...

       

      Can anyone please help me what I'm doing wrong here. Why is there a difference between Release and Debug mode?

       

      Best regards

      Simon

        • 1. Re: PSoC 4 Pioneer Kit: Debug vs Release: Timer not working in release mode
          DheerajK_81

          I can see that you have power-saving modes enabled. Incorrectly putting the unit into low-power modes or not turning on interrupts for peripherals/ISRs will cause it to never wake up again upon button push or using WDT. Double check that you are doing the push button interrupts/wakeup events properly to handle low power modes.

           

          Add "WDT_Interrupt_Enable();" in your main() and the following in your timer isr:

          CY_ISR(timer_handler)
          {
              timer_isr_ClearPending();
              timer_isr_Disable();
              seconds++;
              timer_isr_Enable();
          }
          

           

          After programming, go to Debug > Attach to running target

           

          You will notice the code is stuck in CyExitCriticalSection() in the cyPM.c file in sleep mode:

          void CySysPmSleep(void)
          {
              uint8 interruptState;
          
              interruptState = CyEnterCriticalSection();
          
              /* CPU enters Sleep mode upon execution of WFI */
              CY_PM_CPU_SCR_REG &= (uint32) (~CY_PM_CPU_SCR_SLEEPDEEP);
          
              /* Sleep and wait for interrupt */
              CY_PM_WFI;
          
              CyExitCriticalSection(interruptState);
          }
          

           

          Also, change the interrupt priorities for bless to 0 in the *.cydwr file -> interrupt.

           

          Regards,

          Dheeraj