readme_threadx.txt
1 Microsoft's Azure RTOS ThreadX for Cortex-M23
2
3 Using the AC6 Tools in Keil uVision
4
51. Import the ThreadX Projects
6
7In order to build the ThreadX library and the ThreadX demonstration, first open
8the AzureRTOS.uvmpw workspace (located in the "example_build" directory)
9into Keil.
10
11
122. Building the ThreadX run-time Library
13
14Building the ThreadX library is easy; simply set the ThreadX_Library project
15as active, then then build the library. You should now observe the compilation
16and assembly of the ThreadX library. This project build produces the ThreadX
17library file ThreadX_Library.lib.
18Files tx_thread_stack_error_handler.c and tx_thread_stack_error_notify.c
19replace the common files of the same name.
20
21
223. Demonstration System
23
24The ThreadX demonstration is designed to execute under the Keil debugger on the
25FVP_MPS2_Cortex-M23_MDK simulator.
26
27Building the demonstration is easy; simply select the "Batch Build" button.
28You should now observe the compilation and assembly of the ThreadX demonstration of
29both the demo_secure_zone and demo_threadx_non-secure_zone projects.
30Then click the Start/Stop Debug Session button to start the simulator and begin debugging.
31You are now ready to execute the ThreadX demonstration.
32
33
344. System Initialization
35
36The entry point in ThreadX for the Cortex-M23 using AC6 tools uses the standard AC6
37Cortex-M23 reset sequence. From the reset vector the C runtime will be initialized.
38
39The ThreadX tx_initialize_low_level.S file is responsible for setting up
40various system data structures, the vector area, and a periodic timer interrupt
41source.
42
43In addition, _tx_initialize_low_level determines the first available
44address for use by the application, which is supplied as the sole input
45parameter to your application definition function, tx_application_define.
46
47
485. Register Usage and Stack Frames
49
50The following defines the saved context stack frames for context switches
51that occur as a result of interrupt handling or from thread-level API calls.
52All suspended threads have the same stack frame in the Cortex-M23 version of
53ThreadX. The top of the suspended thread's stack is pointed to by
54tx_thread_stack_ptr in the associated thread control block TX_THREAD.
55
56
57 Stack Offset Stack Contents
58
59 0x00 LR Interrupted LR (LR at time of PENDSV)
60 0x04 r8
61 0x08 r9
62 0x0C r10
63 0x10 r11
64 0x14 r4
65 0x18 r5
66 0x1C r6
67 0x20 r7
68 0x24 r0 (Hardware stack starts here!!)
69 0x28 r1
70 0x2C r2
71 0x30 r3
72 0x34 r12
73 0x38 lr
74 0x3C pc
75 0x40 xPSR
76
77
786. Improving Performance
79
80To make ThreadX and the application(s) run faster, you can enable
81all compiler optimizations.
82
83In addition, you can eliminate the ThreadX basic API error checking by
84compiling your application code with the symbol TX_DISABLE_ERROR_CHECKING
85defined.
86
87
887. Interrupt Handling
89
90ThreadX provides complete and high-performance interrupt handling for Cortex-M23
91targets. There are a certain set of requirements that are defined in the
92following sub-sections:
93
94
957.1 Vector Area
96
97The Cortex-M23 vectors start at the label __Vectors or similar. The application may modify
98the vector area according to its needs. There is code in tx_initialize_low_level() that will
99configure the vector base register.
100
101
1027.2 Managed Interrupts
103
104ISRs can be written completely in C (or assembly language) without any calls to
105_tx_thread_context_save or _tx_thread_context_restore. These ISRs are allowed access to the
106ThreadX API that is available to ISRs.
107
108ISRs written in C will take the form (where "your_C_isr" is an entry in the vector table):
109
110void your_C_isr(void)
111{
112
113 /* ISR processing goes here, including any needed function calls. */
114}
115
116ISRs written in assembly language will take the form:
117
118
119 .global your_assembly_isr
120 .thumb_func
121your_assembly_isr:
122; VOID your_assembly_isr(VOID)
123; {
124 PUSH {r0, lr}
125;
126; /* Do interrupt handler work here */
127; /* BL <your interrupt routine in C> */
128
129 POP {r0, r1}
130 MOV lr, r1
131 BX lr
132; }
133
134
135Note: the Cortex-M23 requires exception handlers to be thumb labels, this implies bit 0 set.
136To accomplish this, the declaration of the label has to be preceded by the assembler directive
137.thumb_func to instruct the linker to create thumb labels. The label __tx_IntHandler needs to
138be inserted in the correct location in the interrupt vector table. This table is typically
139located in either your runtime startup file or in the tx_initialize_low_level.S file.
140
141
1428. Revision History
143
144For generic code revision information, please refer to the readme_threadx_generic.txt
145file, which is included in your distribution. The following details the revision
146information associated with this specific port of ThreadX:
147
14806-02-2021 Release 6.1.7 changes:
149 tx_port.h Remove unneeded include file
150 tx_thread_secure_stack_initialize.S New file
151 tx_thread_schedule.S Added secure stack initialize to SVC hander
152 tx_thread_secure_stack.c Fixed stack pointer save, initialize in handler mode
153
154
15504-02-2021 Release 6.1.6 changes:
156 tx_port.h Updated macro definition
157 tx_thread_schedule.s Added low power support
158
15903-02-2021 The following files were changed/added for version 6.1.5:
160 tx_port.h Added ULONG64_DEFINED
161
16209-30-2020 Initial ThreadX 6.1 version for Cortex-M23 using AC6 tools.
163
164
165Copyright(c) 1996-2020 Microsoft Corporation
166
167
168https://azure.com/rtos
169
170