We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'am using the STM32 and tried to use the ITM-Viewer. At the Keil documentation "Using the ITM Viewer" is a code example of the fputc() function.
int fputc(int ch, FILE *f) { if (DEMCR & TRCENA) { while (ITM_Port32(0) == 0); ITM_Port8(0) = ch; } return(ch); }
This function call will end at a hardware fault. The check if the trace is activated ( if (DEMCR & TRCENA) { )seems to be the source of this hardware fault. If I keep a way this check the ITM Viewer is working fine. Does anybody know, if I have to be at privileged mode to have access to the DEMCR register?
Thanks for help.
Behavior of Cortex-M3 core registers is described in the cortex-M3 TRM (provided by ARM).
In reality all registers in the PPB (Private Peripheral Bus) allow only privileged access. Those registers are from 0xE0000000 to 0xE00FFFFF and include ITM, DWT, FPB, SCS (NVIC, MPU ...), TPIU, ETM.
Only a few registers can be accessed from unprivileged mode like ITM where all registers can be read and Stimulus Ports can be written (conditionally also Trace Enable can be written). Also SW Trigger Interrupt (in NVIC) can be written from unprivileged mode if enabled in the Configuration Control Register.