📄 os_cpu_a.txt
字号:
123 ; + 1 B
124 ; + 2 A
125 ; + 3 X (H)
126 ; + 4 X (L)
127 ; + 5 Y (H)
128 ; + 6 Y (L)
129 ; + 7 PC(H)
130 ; + 8 PC(L)
131 ;********************************************************************************************************
132
133 000c _OSCtxSw:
134 000c fe0000 ldx _OSTCBCur ; 3~, Point to current task's TCB
135 000f 6f00 sts 0,x ; 3~, Save stack pointer in preempted task's TCB
136
137 0011 160000 jsr _OSTaskSwHook ; 4~, Call user task switch hook
138
139 0014 fe0000 ldx _OSTCBHighRdy ; 3~, OSTCBCur = OSTCBHighRdy
140 0017 7e0000 stx _OSTCBCur ; 3~
141
142 001a f60000 ldab _OSPrioHighRdy ; 3~, OSPrioCur = OSPrioHighRdy
143 001d 7b0000 stab _OSPrioCur ; 3~
144
145 0020 ef00 lds 0,x ; 3~, Load SP into 68HC12
146
147 0022 0b rti ; 8~, Run task
148
149 ;********************************************************************************************************
150 ; INTERRUPT LEVEL CONTEXT SWITCH
151 ;
152 ; Description : This function is called by OSIntExit() to perform a context switch to a task that has
153 ; been made ready-to-run by an ISR.
154 ;
155 ; Arguments : none
156 ;
157 ; Note(s) : 1) Stack frame upon entry (Assuming OS_CRITICAL_METHOD is 1):
158 ;
159 ; ---- SP + 0 -> PC(H) \ Return address from call to OSIntCtxSw()
160 ; SP Adjustment | SP + 1 -> PC(L) /
161 ; (+4) | SP + 2 -> PC(H) \ Return address from call to OSIntExit()
162 ; | SP + 3 -> PC(L) /
163 ; --> SP + 4 -> CCR \
164 ; SP + 5 -> B |
165 ; SP + 6 -> A |
166 ; SP + 7 -> X(H) | Stack frame from interrupt stacking.
167 ; SP + 8 -> X(L) |
168 ; SP + 9 -> Y(H) |
169 ; SP + 10 -> Y(L) |
170 ; SP + 11 -> PC(H) |
171 ; SP + 12 -> PC(L) /
172 ;********************************************************************************************************
173
174 0023 _OSIntCtxSw:
175 0023 1b84 leas 4,sp ; 2~, Clean up stack (Uncomment if OS_CRITICAL_METHOD is 1)
176 ; leas 5,sp ; 2~, Clean up stack (Uncomment if OS_CRITICAL_METHOD is 2)
177
178 0025 fd0000 ldy _OSTCBCur ; 3~, OSTCBCur->OSTCBStkPtr = Stack Pointer
179 0028 6f40 sts 0,y ; 3~,
180
181 002a 160000 jsr _OSTaskSwHook ; 4~, Call user task switch hook
182
183 002d fe0000 ldx _OSTCBHighRdy ; 3~, OSTCBCur = OSTCBHighRdy
184 0030 7e0000 stx _OSTCBCur ; 3~
185
186 0033 f60000 ldab _OSPrioHighRdy ; 3~, OSPrioCur = OSPrioHighRdy
187 0036 7b0000 stab _OSPrioCur ; 3~
188
189 0039 ef00 lds 0,x ; 3~, Load SP into 68HC12
190
191 003b 0b rti ; 8~, Run task
192
193 ;********************************************************************************************************
194 ; SYSTEM TICK ISR
195 ;
196 ; Description : This function is the ISR used to notify uC/OS-II that a system tick has occurred. You
197 ; must setup the 68HC12's interrupt vector table so that an OUTPUT COMPARE interrupt
198 ; vectors to this function.
199 ;
200 ; Arguments : none
201 ;
202 ; Notes : 1) The 'tick ISR' assumes the we are using the Output Compare specified by OS_TICK_OC
203 ; (see OS_CFG.H and this file) to generate a tick that occurs every OS_TICK_OC_CNTS
204 ; (see OS_CFG.H and this file) which corresponds to the number of FRT (Free Running
205 ; Timer) counts to the next interrupt.
206 ;
207 ; 2) You must specify which output compare will be used by the tick ISR as follows:
208 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 0 to use OUTPUT COMPARE #0
209 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 1 to use OUTPUT COMPARE #1
210 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 2 to use OUTPUT COMPARE #2
211 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 3 to use OUTPUT COMPARE #3
212 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 4 to use OUTPUT COMPARE #4
213 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 5 to use OUTPUT COMPARE #5
214 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 6 to use OUTPUT COMPARE #6
215 ; Set OS_TICK_OC in OS_CFG.H (AND in this file) to 7 to use OUTPUT COMPARE #7
216 ;
217 ; 3) TFLG1, TC0 ... TC7 are defined in this file.
218 ;********************************************************************************************************
219
220 003c _OSTickISR:
221 003c 720000 inc _OSIntNesting ; 4~, Notify uC/OS-II about ISR
222
230
238
246
254
262
270
278
280 003f c680 ldab #$80 ; 2~, Clear C7F interrupt flag (bit 7)
281 0041 5b8e stab TFLG1 ; 4~
282 0043 dc9e ldd TC7 ; 5~, Set TC7 to present time + desired counts to next ISR
283 0045 c31388 addd #OS_TICK_OC_CNTS ; 4~
284 0048 5c9e std TC7 ; 5~
286
287 004a 10ef cli ; 2~, Enable interrupts to allow interrupt nesting
288
289 004c 160000 jsr _OSTimeTick ; 6~+, Call uC/OS-II's tick updating function
290
291 004f 160000 jsr _OSIntExit ; 6~+, Notify uC/OS-II about end of ISR
292
293 0052 0b rti ; 12~, Return from interrupt, no higher priority tasks ready.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -