📄 os-task-switch.lst
字号:
(0231) {
(0232) #if OS_STRICT
(0233) if(i!=ptcb->OSTCBPrio)
01DA 8025 LDD R2,5+Z
01DB 1562 CP R22,R2
01DC F011 BEQ 0x01DF
(0234) OSError(0);
01DD 2700 CLR R16
01DE D0C2 RCALL _OSError
(0235) #endif
(0236) ret=ptcb->OSTCBPrio;
01DF 2DEA MOV R30,R10
01E0 2DFB MOV R31,R11
01E1 8145 LDD R20,5+Z
(0237) #if OS_STRICT
(0238) if(ret>OS_LOWEST_PRIO)
01E2 E082 LDI R24,2
01E3 1784 CP R24,R20
01E4 F438 BCC 0x01EC
(0239) OSError(0);
01E5 2700 CLR R16
01E6 D0BA RCALL _OSError
(0240) #endif
(0241) break;//for
01E7 C004 RJMP 0x01EC
01E8 9563 INC R22
01E9 3063 CPI R22,3
01EA F408 BCC 0x01EC
01EB CFD7 RJMP 0x01C3
(0242) }
(0243) //OS_EXIT_CRITICAL();
(0244) }
(0245) return ret;
01EC 2F04 MOV R16,R20
01ED D188 RCALL pop_gset3
01EE 9508 RET
(0246) }
(0247)
(0248) /*
(0249) *********************************************************************************************************
(0250) * PROCESS SYSTEM TICK
(0251) *
(0252) * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
(0253) * as a 'clock tick'). This function should be called by the ticker ISR but, can also be
(0254) * called by a high priority task.
(0255) *
(0256) * Arguments : none
(0257) *
(0258) * Returns : none
(0259) *********************************************************************************************************
(0260) */
(0261)
(0262) void OSTimeTick (void)
(0263) {
(0264) INT8U i,ret;
(0265) OS_TCB *ptcb;
(0266) //skip last task,last task must be idle task
(0267) for(i=0;i<OS_TASK_COUNT-1;i++)
_OSTimeTick:
ret --> Y+1
ptcb --> R16
i --> R18
01EF 2722 CLR R18
01F0 C028 RJMP 0x0219
(0268) {
(0269) ptcb=OSpTCBList[i];
01F1 EF8A LDI R24,0xFA
01F2 E091 LDI R25,1
01F3 2FE2 MOV R30,R18
01F4 D1E1 RCALL 0x03D6
01F5 8100 LDD R16,0+Z
01F6 8111 LDD R17,1+Z
(0270) // OS_ENTER_CRITICAL();
(0271) //check ptcb != 0
(0272) if(ptcb){ /* Go through all TCBs in TCB list */
01F7 3000 CPI R16,0
01F8 0701 CPC R16,R17
01F9 F0F1 BEQ 0x0218
(0273) if (ptcb->OSTCBDly != 0) { /* Delayed or waiting for event with TO */
01FA 2FE0 MOV R30,R16
01FB 2FF1 MOV R31,R17
01FC 8022 LDD R2,2+Z
01FD 8033 LDD R3,3+Z
01FE 2022 TST R2
01FF F411 BNE 0x0202
0200 2033 TST R3
0201 F0B1 BEQ 0x0218
(0274) if (--ptcb->OSTCBDly == 0) { /* Decrement nbr of ticks to end of delay */
0202 2F80 MOV R24,R16
0203 2F91 MOV R25,R17
0204 9602 ADIW R24,2
0205 2FE8 MOV R30,R24
0206 2FF9 MOV R31,R25
0207 8180 LDD R24,0+Z
0208 8191 LDD R25,1+Z
0209 9701 SBIW R24,1
020A 2E48 MOV R4,R24
020B 2E59 MOV R5,R25
020C 8240 STD R4,0+Z
020D 8251 STD R5,1+Z
020E 3080 CPI R24,0
020F 0789 CPC R24,R25
0210 F409 BNE 0x0212
(0275) // if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) { /* Is task suspended? */
(0276) // OSRdyGrp |= ptcb->OSTCBBitY; /* No, Make task Rdy to Run (timed out)*/
(0277) // OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
(0278) } else { /* Yes, Leave 1 tick to prevent ... */
0211 C006 RJMP 0x0218
(0279) ptcb->OSTCBDly = 1; /* ... loosing the task when the ... */
0212 E081 LDI R24,1
0213 E090 LDI R25,0
0214 2FE0 MOV R30,R16
0215 2FF1 MOV R31,R17
0216 8382 STD R24,2+Z
0217 8393 STD R25,3+Z
0218 9523 INC R18
0219 3022 CPI R18,2
021A F408 BCC 0x021C
021B CFD5 RJMP 0x01F1
(0280) } /* ... suspension is removed. */
(0281) }//end OSTCBDly!=0
(0282) }//end if(ptcb)
(0283) // OS_EXIT_CRITICAL();
(0284) }//end for
(0285) }
021C 9508 RET
(0286)
(0287) /*
(0288) *********************************************************************************************************
(0289) * EXIT ISR
(0290) *
(0291) * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When
(0292) * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
(0293) * a new, high-priority task, is ready to run.
(0294) *
(0295) * Arguments : none
(0296) *
(0297) * Returns : none
(0298) *
(0299) * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call
(0300) * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
(0301) * end of the ISR.
(0302) * 2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
(0303) *********************************************************************************************************
(0304) */
(0305)
(0306) void OSIntExit(void)
(0307) {
(0308) OS_ENTER_CRITICAL();
_OSIntExit:
021D 930A ST R16,-Y
021E B70F IN R16,P3F
021F 94F8 BCLR 7
0220 930F PUSH R16
0221 9109 LD R16,Y+
(0309) if ((--OSIntNesting | OSLockNesting) == 0) { /* Reschedule only if all ISRs completed & not locked */
0222 918001F9 LDS R24,_OSIntNesting
0224 5081 SUBI R24,1
0225 2E28 MOV R2,R24
0226 922001F9 STS R2,_OSIntNesting
0228 904001F8 LDS R4,_OSLockNesting
022A 2824 OR R2,R4
022B F009 BEQ 0x022D
022C C029 RJMP 0x0256
(0310) OSPrioHighRdy=OSGetPrioRdy();
022D DF91 RCALL _OSGetPrioRdy
022E 930001F6 STS R16,_OSPrioHighRdy
(0311) if(OSPrioHighRdy>OS_LOWEST_PRIO)
0230 E082 LDI R24,2
0231 1780 CP R24,R16
0232 F418 BCC 0x0236
(0312) {
(0313) #if OS_STRICT
(0314) OSError(0);
0233 2700 CLR R16
0234 D06C RCALL _OSError
(0315) #endif
(0316) }else if (OSPrioHighRdy != OSPrioCur) { /* No context switch if current task is highest ready */
0235 C020 RJMP 0x0256
0236 D1C3 RCALL 0x03FA
0237 F0F1 BEQ 0x0256
(0317) OSTCBHighRdy = OSpTCBList[OSPrioHighRdy];
0238 EF8A LDI R24,0xFA
0239 E091 LDI R25,1
023A 2DE3 MOV R30,R3
023B D19A RCALL 0x03D6
023C D1A7 RCALL 0x03E4
(0318) #if OS_STRICT
(0319) if((0==OSTCBHighRdy)||(0==OSTCBCur)||
023D 2022 TST R2
023E F411 BNE 0x0241
023F 2033 TST R3
0240 F089 BEQ 0x0252
0241 902001F4 LDS R2,_OSTCBCur
0243 903001F5 LDS R3,_OSTCBCur+1
0245 2022 TST R2
0246 F411 BNE 0x0249
0247 2033 TST R3
0248 F049 BEQ 0x0252
0249 E082 LDI R24,2
024A 902001F7 LDS R2,_OSPrioCur
024C 1582 CP R24,R2
024D F020 BCS 0x0252
024E 902001F6 LDS R2,_OSPrioHighRdy
0250 1582 CP R24,R2
0251 F410 BCC 0x0254
(0320) (OSPrioCur>OS_LOWEST_PRIO)||(OSPrioHighRdy>OS_LOWEST_PRIO))
(0321) OSError(0);
0252 2700 CLR R16
0253 D04D RCALL _OSError
(0322) #endif
(0323) OSDebug();
0254 D006 RCALL _OSDebug
(0324) OSIntCtxSw(); /* Perform interrupt level context switch */
0255 DE11 RCALL _OSIntCtxSw
(0325) }//end OSPrioHighRdy != OSPrioCur
(0326) }//end nesting==0
(0327) OS_EXIT_CRITICAL();
0256 930A ST R16,-Y
0257 910F POP R16
0258 BF0F OUT P3F,R16
0259 9109 LD R16,Y+
(0328) }
025A 9508 RET
(0329)
(0330) void OSDebug(void)
(0331) {
(0332) INT8U port_a;
(0333) //debug
(0334) DDRA=0;port_a=PORTA;
_OSDebug:
port_a --> R16
025B 2422 CLR R2
025C BA2A OUT P1A,R2
025D B30B IN R16,P1B
(0335) DDRA=0xff;PORTA=~port_a;
025E EF8F LDI R24,0xFF
025F BB8A OUT P1A,R24
0260 2E20 MOV R2,R16
0261 9420 COM R2
0262 BA2B OUT P1B,R2
(0336) //end debug
(0337) }
0263 9508 RET
FILE: G:\编程2002-10-15-HOME\做过的项目\2002-10-22\home-c\software\ucos-ii-at90S-icc-avr\os-task-switch\test_funcs.c
(0001) #include "includes.h"
(0002)
(0003) //*****************************************************************************
(0004) // TickISR
(0005) //*****************************************************************************
(0006) // Init Timer/Counter2 fuer Takterzeugung
(0007) void TC2_Init (void){
(0008) TCCR0 = 0x05; /* Set TIMER0 prescaler to CLK/1024 */
_TC2_Init:
0264 E085 LDI R24,5
0265 BF83 OUT P33,R24
(0009) TIMSK = 0x02; /* Enable TIMER0 overflow interrupt */
0266 E082 LDI R24,2
0267 BF89 OUT P39,R24
(0010) }
0268 9508 RET
_Delay:
i --> R16
j --> R18
k --> R20
0269 D0EA RCALL push_gset1
(0011)
(0012) void Delay(void)
(0013) {
(0014) unsigned char i,j,k;
(0015) for(i=1;i<10;i++)
026A E001 LDI R16,1
026B C00B RJMP 0x0277
(0016) for(j=1;j;j++)
026C E021 LDI R18,1
026D C006 RJMP 0x0274
(0017) {
(0018) for(k=1;k;k++)
026E E041 LDI R20,1
026F C001 RJMP 0x0271
0270 9543 INC R20
0271 2344 TST R20
0272 F7E9 BNE 0x0270
0273 9523 INC R18
0274 2322 TST R18
0275 F7C1 BNE 0x026E
0276 9503 INC R16
0277 300A CPI R16,0xA
0278 F398 BCS 0x026C
(0019) ;
(0020) }
(0021) }
0279 D0DD RCALL pop_gset1
027A 9508 RET
_task_Delay:
k --> Y+1
j --> Y+1
i --> R20
027B D0D8 RCALL push_gset1
(0022)
(0023) void task_Delay(void)
(0024) {
(0025) unsigned char i,j,k;
(0026) for(i=1;i<2;i++)
027C E041 LDI R20,1
027D C004 RJMP 0x0282
(0027) // for(j=1;j;j++)
(0028) {
(0029) OSTimeDly(3);
027E E003 LDI R16,3
027F E010 LDI R17,0
0280 DF2C RCALL _OSTimeDly
0281 9543 INC R20
0282 3042 CPI R20,2
0283 F3D0 BCS 0x027E
(0030) // for(k=1;k;k++) ;
(0031) }
(0032) }
0284 D0D2 RCALL pop_gset1
0285 9508 RET
_ProgramStart_Flash:
v --> R20
0286 D0CD RCALL push_gset1
0287 2F40 MOV R20,R16
(0033)
(0034) void ProgramStart_Flash(INT8U v)
(0035) {
(0036) DDRB=0xff;
0288 EF8F LDI R24,0xFF
0289 BB87 OUT P17,R24
(0037) PORTB=v;
028A BB48 OUT P18,R20
(0038) DDRD=0xff;
028B BB81 OUT P11,R24
(0039) PORTD=v;
028C BB42 OUT P12,R20
(0040) // DDRA=0xff; PORTA=v;
(0041) // DDRC=0xff;
(0042) // PORTC=v;
(0043) Delay();
028D DFDB RCALL _Delay
(0044) }
028E D0C8 RCALL pop_gset1
028F 9508 RET
(0045)
(0046) void ProgramStart(void)
(0047) {
(0048) DDRA=0xff; PORTA=0xff;
_ProgramStart:
0290 EF8F LDI R24,0xFF
0291 BB8A OUT P1A,R24
0292 BB8B OUT P1B,R24
(0049) DDRC=0xff; PORTC=0xff;
0293 BB84 OUT P14,R24
0294 BB85 OUT P15,R24
(0050) ProgramStart_Flash(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -