Skip to content

Commit 0ac6a71

Browse files
author
Marcus Chang
committed
Added missing sections to itm.md
1 parent adab5a4 commit 0ac6a71

File tree

1 file changed

+22
-8
lines changed
  • docs/reference/contributing/target

1 file changed

+22
-8
lines changed

docs/reference/contributing/target/itm.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,32 @@ For targets with Arm CoreSight (for example, Cortex-M3 and Cortex-M4), the Instr
44

55
#### Assumptions
66

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-
107
##### Defined behavior
118

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.
1610

1711
##### Undefined behavior
1812

1913
- 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.
2033

2134
#### Testing
2235

@@ -25,7 +38,8 @@ You can use the `SerialWireOutput` to send `stdout` to the SWO stimulus port on
2538
```
2639
#include "SerialWireOutput.h"
2740
28-
FileHandle* mbed::mbed_override_console(int fd) {
41+
FileHandle* mbed::mbed_override_console(int fd)
42+
{
2943
static SerialWireOutput swo;
3044
return &swo;
3145
}

0 commit comments

Comments
 (0)