Skip to content

Commit c78bcd7

Browse files
author
Marcus Chang
authored
Create itm.md
Documentation for the new ITM HAL API: ARMmbed/mbed-os#5956
1 parent 8cad033 commit c78bcd7

File tree

1 file changed

+34
-0
lines changed
  • docs/reference/contributing/target

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Instrumented Trace Macrocell
2+
3+
For targets with Arm CoreSight (e.g. Cortex-M3 and Cortex-M4) the Instrumented Trace Macrocell provides a lightweight, non-intrusive way for collecting debug trace output.
4+
5+
#### Assumptions
6+
7+
* The target supports Arm CoreSight.
8+
* The target has SWO connected either to a compatible interface chip or exposed as a debug pin.
9+
10+
##### Defined behavior
11+
12+
* Targets must implement the function `void itm_init(void)` and add `ITM` to the `device_has` section in `target.json`.
13+
* When `void itm_init(void)` is called, the debug clock for the ITM must be initialized and the SWO pin configured for debug output.
14+
* `void itm_init(void)` should only have to modify the clock pre-scaler in the generic register `TPI->ACPR`. The generic ITM registers will be initialized by the helper function `mbed_itm_init`.
15+
* `void itm_init(void)` will only be called once during startup and doesn't have to be protected for multiple calls.
16+
17+
##### Undefined behavior
18+
19+
* The debug clock frequency is left undefined since the most optimal frequency will vary from target to target. It is up to each target's owner to pick a frequency that (a) doesn't interfere with normal operation and (b) is supported by the owner's preferred debug monitor.
20+
21+
#### Testing
22+
23+
The `SerialWireOutput` class can be used for sending `stdout` to the SWO stimulus port on the ITM by including this override function:
24+
25+
```
26+
#include "SerialWireOutput.h"
27+
28+
FileHandle* mbed::mbed_override_console(int fd) {
29+
static SerialWireOutput swo;
30+
return &swo;
31+
}
32+
```
33+
34+
The function can be placed in any C++ compilation unit, including `main.cpp`.

0 commit comments

Comments
 (0)