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

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

cross mob
lock attach
Attachments are accessible only for community members.
SiSc_4153271
Level 1
Level 1

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-B...

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

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

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

View solution in original post

0 Likes
1 Reply
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

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

0 Likes