Other Parts Discussed in Thread: CC1312R7
This is a follow-up to this thread: https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1254569/cc1314r10-are-there-any-limitations-to-using-arm-dwt_cyccnt-for-implementing-delays-or-measuring-cycle-counts-in-source-code
Below lines of code for providing delay are working ok on CC1312 with and without live debugging with jlink debugger connected to the board.
/* Enable DWT */ HWREG( CPU_DCB_BASE + CPU_DCB_O_DEMCR) |= CPU_DCB_DEMCR_TRCENA; /* Enable CPU cycle counter */ HWREG( CPU_DWT_BASE + CPU_DWT_O_CTRL) |= CPU_DWT_CTRL_CYCCNTENA; /* Reset CPU cycle counter */ HWREG( CPU_DWT_BASE + CPU_DWT_O_CYCCNT) = 0; //Wait for delay while(HWREG( CPU_DWT_BASE + CPU_DWT_O_CYCCNT) < delay);
But for CC1314,
- These lines are working ok when live debugging with jlink debugger.
- Stuck at while(HWREG( CPU_DWT_BASE + CPU_DWT_O_CYCCNT) < delay); when debugger not connected.
Seems like cycle count is not incrementing.
` After doing further analysis I understood from ARM documentation form M33 that there is DWT access register DWT_LAR which need to be configured. So, I implemented below statement before accessing DWT.
#define CPU_DWT_O_LAR 0x00000FB0
HWREG(CPU_DWT_BASE + CPU_DWT_O_LAR) = 0xC5ACCE55;
But even after implementing this, code stuck at while loop without debugger connected to board. Although with jlink live debugging, it is still working ok.
I also noticed that DWT access enable register is not implemented in sdk header file hw_cpu_dwt.h. But is available in IAR IDE registers view as below.
So, please let me know how to implement DWT cycle count access on CC1314?