You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/contributing/target/itm.md
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,32 @@ For targets with Arm CoreSight (for example, Cortex-M3 and Cortex-M4), the Instr
4
4
5
5
#### Assumptions
6
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
7
##### Defined behavior
11
8
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)` only has to modify the clock prescaler in the generic register `TPI->ACPR`. The helper function `mbed_itm_init` initializes the generic ITM registers.
15
-
-`void itm_init(void)` is only called once during startup and doesn't have to be protected for multiple calls.
9
+
- When initialized, writing data to the ITM stimulus registers will result in the data being transmitted over the SWO line.
16
10
17
11
##### Undefined behavior
18
12
19
13
- The debug clock frequency is left undefined because the most optimal frequency varies from target to target. It is up to each target's owner to choose a frequency that doesn't interfere with normal operation and that the owner's preferred debug monitor supports.
14
+
- If another peripheral tries to take control of the SWO pin it is undefined whether that operation should succeed or not.
15
+
16
+
##### Notes
17
+
18
+
- Some SWO viewers do not allow for an arbitrary frequency to be set. Make sure that the chosen frequency is supported by the development tools you expect your users to use.
19
+
20
+
#### Dependencies
21
+
22
+
- The target supports Arm CoreSight.
23
+
- The target has SWO connected either to a compatible interface chip or exposed as a debug pin.
24
+
25
+
#### Implementing the ITM API
26
+
27
+
- You must implement the function `itm_init`. When the function is called:
28
+
- The debug clock for the ITM must be initialized.
29
+
- The SWO pin must be configured for debug output.
30
+
- You must add `ITM` to the `device_has` section in `target.json`.
31
+
32
+
It should not be necessary to mofify any of the ITM registers in `itm_init`, except for the one related to the clock prescaling, `TPI->ACPR`. The helper function `mbed_itm_init` is responsible for calling `itm_init` and initializing the generic ITM registers. `mbed_itm_init` will only call the function `itm_init` exactly once making it unnecessary to protect `itm_init` against multiple initializations.
20
33
21
34
#### Testing
22
35
@@ -25,7 +38,8 @@ You can use the `SerialWireOutput` to send `stdout` to the SWO stimulus port on
0 commit comments