Skip to content

Commit 229fdf0

Browse files
aaronyegxkartben
authored andcommitted
logging: backends: Use CMSIS 6 register defines in SWO initialization
ARM CMSIS 6 has different ITM and TPI register definition comparing with CMSIS 5. Update the swo initialization to use CMSIS 6 defines. For the Cortex-M cores which are higher than Cortex-CM7, the LAR has been removed from ITM. Signed-off-by: Aaron Ye <[email protected]>
1 parent ee2ebbd commit 229fdf0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

subsys/logging/backends/log_backend_swo.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,25 @@ static void log_backend_swo_init(struct log_backend const *const backend)
9494
{
9595
/* Enable DWT and ITM units */
9696
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
97+
#if (__CORTEX_M <= 7U)
9798
/* Enable access to ITM registers */
9899
ITM->LAR = 0xC5ACCE55;
100+
#endif
99101
/* Disable stimulus ports ITM_STIM0-ITM_STIM31 */
100102
ITM->TER = 0x0;
101103
/* Disable ITM */
102104
ITM->TCR = 0x0;
103105
/* Select TPIU encoding protocol */
104-
TPI->SPPR = IS_ENABLED(CONFIG_LOG_BACKEND_SWO_PROTOCOL_NRZ) ? 2 : 1;
106+
TPIU->SPPR = IS_ENABLED(CONFIG_LOG_BACKEND_SWO_PROTOCOL_NRZ) ? 2 : 1;
105107
/* Set SWO baud rate prescaler value: SWO_clk = ref_clock/(ACPR + 1) */
106-
TPI->ACPR = SWO_FREQ_DIV - 1;
108+
TPIU->ACPR = SWO_FREQ_DIV - 1;
107109
/* Enable unprivileged access to ITM stimulus ports */
108110
ITM->TPR = 0x0;
109111
/* Configure Debug Watchpoint and Trace */
110112
DWT->CTRL &= (DWT_CTRL_POSTPRESET_Msk | DWT_CTRL_POSTINIT_Msk | DWT_CTRL_CYCCNTENA_Msk);
111113
DWT->CTRL |= (DWT_CTRL_POSTPRESET_Msk | DWT_CTRL_POSTINIT_Msk);
112114
/* Configure Formatter and Flush Control Register */
113-
TPI->FFCR = 0x00000100;
115+
TPIU->FFCR = 0x00000100;
114116
/* Enable ITM, set TraceBusID=1, no local timestamp generation */
115117
ITM->TCR = 0x0001000D;
116118
/* Enable stimulus port used by the logger */

0 commit comments

Comments
 (0)