4 <title>CMSIS Debug Support</title>
\r
5 <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
\r
6 <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
\r
7 <meta name="ProgId" content="FrontPage.Editor.Document">
\r
10 /*-----------------------------------------------------------
\r
11 Keil Software CHM Style Sheet
\r
12 -----------------------------------------------------------*/
\r
13 body { color: #000000; background-color: #FFFFFF; font-size: 75%; font-family:
\r
14 Verdana, Arial, 'Sans Serif' }
\r
15 a:link { color: #0000FF; text-decoration: underline }
\r
16 a:visited { color: #0000FF; text-decoration: underline }
\r
17 a:active { color: #FF0000; text-decoration: underline }
\r
18 a:hover { color: #FF0000; text-decoration: underline }
\r
19 h1 { font-family: Verdana; font-size: 18pt; color: #000080; font-weight: bold;
\r
20 text-align: Center; margin-right: 3 }
\r
21 h2 { font-family: Verdana; font-size: 14pt; color: #000080; font-weight: bold;
\r
22 background-color: #CCCCCC; margin-top: 24; margin-bottom: 3;
\r
24 h3 { font-family: Verdana; font-size: 10pt; font-weight: bold; background-color:
\r
25 #CCCCCC; margin-top: 24; margin-bottom: 3; padding: 6 }
\r
26 pre { font-family: Courier New; font-size: 10pt; background-color: #CCFFCC;
\r
27 margin-left: 24; margin-right: 24 }
\r
28 ul { list-style-type: square; margin-top: 6pt; margin-bottom: 0 }
\r
29 ol { margin-top: 6pt; margin-bottom: 0 }
\r
30 li { clear: both; margin-bottom: 6pt }
\r
31 table { font-size: 100%; border-width: 0; padding: 0 }
\r
32 th { color: #FFFFFF; background-color: #000080; text-align: left; vertical-align:
\r
33 bottom; padding-right: 6pt }
\r
34 tr { text-align: left; vertical-align: top }
\r
35 td { text-align: left; vertical-align: top; padding-right: 6pt }
\r
36 .ToolT { font-size: 8pt; color: #808080 }
\r
37 .TinyT { font-size: 8pt; text-align: Center }
\r
38 code { color: #000000; background-color: #E0E0E0; font-family: 'Courier New', Courier;
\r
39 line-height: 120%; font-style: normal }
\r
40 /*-----------------------------------------------------------
\r
42 -----------------------------------------------------------*/
\r
43 p.note { font-weight: bold; clear: both; margin-bottom: 3pt; padding-top: 6pt }
\r
44 /*-----------------------------------------------------------
\r
45 Expanding/Contracting Divisions
\r
46 -----------------------------------------------------------*/
\r
47 #expand { text-decoration: none; margin-bottom: 3pt }
\r
48 img.expand { border-style: none; border-width: medium }
\r
49 div.expand { display: none; margin-left: 9pt; margin-top: 0 }
\r
50 /*-----------------------------------------------------------
\r
52 -----------------------------------------------------------*/
\r
53 p.wh { font-weight: bold; clear: both; margin-top: 6pt; margin-bottom: 3pt }
\r
54 table.wh { width: 100% }
\r
55 td.whItem { white-space: nowrap; font-style: italic; padding-right: 6pt; padding-bottom:
\r
57 td.whDesc { padding-bottom: 6pt }
\r
58 /*-----------------------------------------------------------
\r
60 -----------------------------------------------------------*/
\r
61 table.kt { border: 1pt solid #000000 }
\r
62 th.kt { white-space: nowrap; border-bottom: 1pt solid #000000; padding-left: 6pt;
\r
63 padding-right: 6pt; padding-top: 4pt; padding-bottom: 4pt }
\r
65 td.kt { color: #000000; background-color: #E0E0E0; border-top: 1pt solid #A0A0A0;
\r
66 padding-left: 6pt; padding-right: 6pt; padding-top: 2pt;
\r
67 padding-bottom: 2pt }
\r
68 /*-----------------------------------------------------------
\r
69 -----------------------------------------------------------*/
\r
77 <h1>CMSIS Debug Support</h1>
\r
81 <h2>Cortex-M3 ITM Debug Access</h2>
\r
83 The Cortex-M3 incorporates the Instrumented Trace Macrocell (ITM) that provides together with
\r
84 the Serial Viewer Output trace capabilities for the microcontroller system. The ITM has
\r
85 32 communication channels which are able to transmit 32 / 16 / 8 bit values; two ITM
\r
86 communication channels are used by CMSIS to output the following information:
\r
89 <li>ITM Channel 0: used for printf-style output via the debug interface.</li>
\r
90 <li>ITM Channel 31: is reserved for RTOS kernel awareness debugging.</li>
\r
93 <h2>Debug IN / OUT functions</h2>
\r
94 <p>CMSIS provides following debug functions:</p>
\r
96 <li>ITM_SendChar (uses ITM channel 0)</li>
\r
97 <li>ITM_ReceiveChar (uses global variable)</li>
\r
98 <li>ITM_CheckChar (uses global variable)</li>
\r
101 <h3>ITM_SendChar</h3>
\r
103 <strong>ITM_SendChar</strong> is used to transmit a character over ITM channel 0 from
\r
104 the microcontroller system to the debug system. <br>
\r
105 Only a 8 bit value is transmitted.
\r
108 static __INLINE uint32_t ITM_SendChar (uint32_t ch)
\r
110 /* check if debugger connected and ITM channel enabled for tracing */
\r
111 if ((CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA) &&
\r
112 (ITM->TCR & ITM_TCR_ITMENA) &&
\r
113 (ITM->TER & (1UL << 0)) )
\r
115 while (ITM->PORT[0].u32 == 0);
\r
116 ITM->PORT[0].u8 = (uint8_t)ch;
\r
121 <h3>ITM_ReceiveChar</h3>
\r
123 ITM communication channel is only capable for OUT direction. For IN direction
\r
124 a globel variable is used. A simple mechansim detects if a character is received.
\r
125 The project to test need to be build with debug information.
\r
129 The globale variable <strong>ITM_RxBuffer</strong> is used to transmit a 8 bit value from debug system
\r
130 to microcontroller system. <strong>ITM_RxBuffer</strong> is 32 bit wide to enshure a proper handshake.
\r
133 extern volatile int ITM_RxBuffer; /* variable to receive characters */
\r
136 A dedicated bit pattern is used to determin if <strong>ITM_RxBuffer</strong> is empty
\r
137 or contains a valid value.
\r
140 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5 /* value identifying ITM_RxBuffer is ready for next character */
\r
143 <strong>ITM_ReceiveChar</strong> is used to receive a 8 bit value from the debug system. The function is nonblocking.
\r
144 It returns the received character or '-1' if no character was available.
\r
147 static __INLINE int ITM_ReceiveChar (void) {
\r
148 int ch = -1; /* no character available */
\r
150 if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
\r
152 ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
\r
159 <h3>ITM_CheckChar</h3>
\r
161 <strong>ITM_CheckChar</strong> is used to check if a character is received.
\r
164 static __INLINE int ITM_CheckChar (void) {
\r
166 if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) {
\r
167 return (0); /* no character available */
\r
169 return (1); /* character available */
\r
174 <h2>ITM Debug Support in uVision</h2>
\r
176 uVision uses in a debug session the <strong>Debug (printf) Viewer</strong> window to
\r
177 display the debug data.
\r
179 <p>Direction microcontroller system -> uVision:</p>
\r
182 Characters received via ITM communication channel 0 are written in a printf style
\r
183 to <strong>Debug (printf) Viewer</strong> window.
\r
187 <p>Direction uVision -> microcontroller system:</p>
\r
189 <li>Check if <strong>ITM_RxBuffer</strong> variable is available (only performed once).</li>
\r
190 <li>Read character from <strong>Debug (printf) Viewer</strong> window.</li>
\r
191 <li>If <strong>ITM_RxBuffer</strong> empty write character to <strong>ITM_RxBuffer</strong>.</li>
\r
194 <p class="Note">Note</p>
\r
196 <li><p>Current solution does not use a buffer machanism for trasmitting the characters.</p>
\r
200 <h2>RTX Kernel awareness in uVision</h2>
\r
202 uVision / RTX are using a simple and efficient solution for RTX Kernel awareness.
\r
203 No format overhead is necessary.<br>
\r
204 uVsion debugger decodes the RTX events via the 32 / 16 / 8 bit ITM write access
\r
205 to ITM communication channel 31.
\r
208 <p>Following RTX events are traced:</p>
\r
210 <li>Task Create / Delete event
\r
212 <li>32 bit access. Task start address is transmitted</li>
\r
213 <li>16 bit access. Task ID and Create/Delete flag are transmitted<br>
\r
214 High byte holds Create/Delete flag, Low byte holds TASK ID.
\r
218 <li>Task switch event
\r
220 <li>8 bit access. Task ID of current task is transmitted</li>
\r
225 <p class="Note">Note</p>
\r
227 <li><p>Other RTOS information could be retrieved via memory read access in a polling mode manner.</p>
\r
232 <p class="MsoNormal"><span lang="EN-GB"> </span></p>
\r
236 <p class="TinyT">Copyright © KEIL - An ARM Company.<br>
\r
237 All rights reserved.<br>
\r
238 Visit our web site at <a href="http://www.keil.com">www.keil.com</a>.
\r