How can I use and view ITM logs with CY8KIT-062S2-43012?

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

cross mob
MoNa_4784221
Level 1
Level 1
First like received

I am trying to debug on the CY8KIT-062S2-43012 kit.

I've been looking into debugging options that would hopefully avoid dependence on a UART module.

Trying to run the debug on the Hello World template example using Modus Toolbox v2.2.

I added my ITM init function :

void itm_init(void)

{

CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

/* Enable Trace debugger*/

ITM->TCR |= 1;

ITM->TER |= 1;

TPI->ACPR=0;

/* Enable write access to ITM registers. */

        ITM->LAR  = 0xC5ACCE55;

        /* Trace Port Interface Selected Pin Protocol Register. */

        TPI->SPPR = (0x02 << TPI_SPPR_TXMODE_Pos);

        /* Trace Port Interface Formatter and Flush Control Register */

        TPI->FFCR = (1 << TPI_FFCR_TrigIn_Pos);

        /* Data Watchpoint and Trace Control Register */

        DWT->CTRL = (1 << DWT_CTRL_CYCTAP_Pos)       |

                    (0xF << DWT_CTRL_POSTINIT_Pos)   |

                    (0xF << DWT_CTRL_POSTPRESET_Pos) |

                    (1 << DWT_CTRL_CYCCNTENA_Pos);

        /* Trace Privilege Register.

         * Disable access to trace channel configuration from non-privileged mode.

         */

        ITM->TPR  = 0x0;

        /* Trace Control Register */

        ITM->TCR  = (1 << ITM_TCR_TraceBusID_Pos) |

                    (1 << ITM_TCR_DWTENA_Pos)     |

                    (1 << ITM_TCR_SYNCENA_Pos)    |

                    (1 << ITM_TCR_ITMENA_Pos);

        /* Trace Enable Register */

        ITM->TER = 0x01;

}

and used the CMSIS ITM_SendChar (uint32_t) function, tried running with J-link lite + SWO-viewer, but I see that nothing happens on the SWO pin.

How can I use and view ITM logs?

7 Replies
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi MoNa_4784221​,

Please refer to the thread: PSOC6 Serial Wire Viewer in which a similar issue is addressed.

Best Regards

Ekta

0 Likes

Hi EktaN_26​,

Thank you for response.

I did all the steps in this post but nothing happens.

1- I created a hello world template example using ModusToolbox because PSoC Creator doesn't support our kit.

2- I made sure that Debug Select SWD+SWO in the Device Configurator and built the project.

3- Exported the project to Keil uVision 5 by following the steps provided in ModusToolbox®️ 2.2 User Guide.

https://www.cypress.com/file/512716/download

4- Redirected the STDERR, STDIN, STDOUT to ITM in Keil uVision IDE's is Run-time Environment.

5- Connected the ULINKpro debugger to the J11 header CY8CKIT-062-BLE board. Rebuilt the project in uVision and started the debug session.

6- in the printf function, the debug session freezing.

7- when I paused the session, I found it in the Cy_Syslib_ProcessingFault function.

swo.PNG

0 Likes
MoNa_4784221
Level 1
Level 1
First like received

freeze.PNG

fault.PNG

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi,

I see you calling the printf statement even before the retarget-io is initialized. Can you please initialize the the retarget-io first and then call the printf statement and let us know if it works.

This is because the retarget-io library, enables you directly print messages on a UART terminal using printf() thus it needs to be initialized first.

Best Regards

Ekta

0 Likes

Hi EktaN_26,

Thank you for your response.

I did that. (Attached the file code.WeTransfer "main.c" )

The debug session doesn't freeze anymore.

But still, I see that nothing happens on the SWO pin.

And nothing showed in the debug viewer.

(figure 1 & 2)

I try to connect the board using "KITPROG3 USB" to see if the debug printf messages sent through uart, I could see the logs over the uart. (figure 3&4)

So it seems that ITM is still not enabled/configured yet.

Image20201122162801.jpg

No data.PNG

{587425CA-96B6-4CD8-981B-4061D42BDC9B&#125;.jpg

debugging.PNG

0 Likes

In your Target Options, under Debug panel, click Settings for ULink2 Pro Debugger. Check if you have enabled trace and the ports for it as highlighted in the screenshot below:

debug.png

Let us know if the issue persists even after these settings have been enabled.

Regards,

Dheeraj

0 Likes

itm.PNG

Yes, I did that.

And the same issue persists.

0 Likes