PSoC 6 MCU CM4 Core Debug Issue - KBA227094

Author: vitas_81           Version: **

 

Question:

I am using PSoC® Creator™ 4.2, PDL 3.1.0, and PSoC Programmer 3.28 tools and trying to debug the CM4 core of PSoC 6 MCUs. Debugging halts in the disassembly and not in main(). How do I get debugging to work properly?

 

Answer:

This issue is caused because system calls added in the startup code of PDL 3.1.0 cannot be executed after the CM4 core debugging session is initiated. PSoC Programmer disables all interrupt notifications in the IPC_INTR_STRUCT.INTR_MASK register except for the debug access port (DAP).  As a result, a system call from PDL is invoked but stuck in the loop polling for the IPC lock released. PSoC Programmer 3.28.3 release will provide the fix for this issue.

In the meantime, you can use one of the following workarounds:

1: In the Cy_SystemInit startup code, typically found in cyfitter_cfg.c:

Set the default value for the CYREG_IPC_INTR_STRUCT0_INTR_MASK register before the call to Cy_SysPm_LdoSetVoltage().

CY_SET_REG32(CYREG_IPC_INTR_STRUCT0_INTR_MASK, 0x00070000u);

Note: Generating the project removes this workaround. You should add this piece of code after the project is generated.

 

2: Put an infinite loop at the start of main_cm4.c

This loop executes until the debugger changes its state after attaching to running target. Execution will then stop inside this loop.

1. Add the following code in main_cm4.c at the start of the main() function:

volatile int flag = 0;
while (flag == 0) {}

2. Program the project to a device.

3. Power cycle the MCU or press the Reset button (if available).

4. In PSoC Creator, select Debug > Attach to Running Target. Select CM4 as the target for the debug probe. Note that Halt target on attach is enabled.

    

The debugger now stops at the infinite loop.

5. Change the value for the flag variable from ‘0’ to any other value.

6. Step over and continue the debug session.

 

If a debugger is not needed anymore and you want to run the CM4 code immediately after a reset event, remove the workaround from main().