summaryrefslogtreecommitdiff
path: root/FreeRTOS-Labs/Source/FreeRTOS-Plus-Trace/streamports/ARM_ITM/Keil-uVision-Tracealyzer-ITM-Exporter.ini
blob: 5e2c8b99b4fbc3f2e568573084f0ebf53f05c529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/************************************************************
* Percepio Tracealyzer - ITM Trace Exporter for Keil uVision
* Copyright (c) 2018, Percepio AB.
* https://percepio.com
************************************************************/

FUNC void tzSetEnable(int enable)
{	
	if (enable == 1)
	{
		printf("Starting Tracealyzer recorder\n"); 		
	
		// Forward the ITM data to file
		exec("ITMLOG 1 > .\\tracealyzer.psf");
		
		// Send start command to Tracealyzer (not required if using vTraceEnable(TRC_START))
		exec("E CHAR tz_host_command_data = 1, 1, 0, 0, 0, 0, 0xFD, 0xFF");
		exec("tz_host_command_bytes_to_read = 8");
	}
	else if (enable == 0)
	{	
		printf("Stopping Tracealyzer recorder...\n"); 
		
		// Send stop command to Tracealyzer, to stop writing ITM data.		
		exec("E CHAR tz_host_command_data = 1, 0, 0, 0, 0, 0, 0xFE, 0xFF");
		exec("tz_host_command_bytes_to_read = 8");

		_sleep_(2000); // Wait a while to let all data be written the host file.
		
		// Stop forwarding the ITM data to file and close the file.
		exec("ITMLOG 1 OFF");
		
		printf("Tracealyzer recorder stopped.\n"); 
		
	}
	else printf("Usage: tzSetEnable(0 or 1), where 0 is disable (stops recorder) and 1 enable (starts recording)");
	
} 


// The Tracealyzer ITM stream port for Keil µVision can be used in two ways.
//
// 1. Start tracing directly from startup. 
// Make sure tzSetEnable(1) is called below and vTraceEnable(TRC_START) in your target startup.
//
// 2. Start the trace manually, using the "Start Recording" button in Keil µVision. 
// In this case, comment out the below call to tzSetEnable and make sure you call vTraceEnable(TRC_INIT) in your target startup (not TRC_START).

tzSetEnable(1);

DEFINE BUTTON "Start Recording", "tzSetEnable(1)";
DEFINE BUTTON "Stop Recording", "tzSetEnable(0)";