⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app_isr.s90

📁 μC/OS—ⅡV:2.80 对 ATMega256 单片机的移植程序代码。
💻 S90
字号:
;********************************************************************************************************
;                                               uC/OS-II
;                                         The Real-Time Kernel
;
;                                       ATmega256  Specific code
;
;
; File     : APP_ISR.S90
; By       : Jean J. Labrosse
;********************************************************************************************************

#include        <os_cpu_i.s90>


                NAME    app_isr

                RSEG    CSTACK:DATA:NOROOT(0)
                RSEG    RSTACK:DATA:NOROOT(0)

;********************************************************************************************************
;                                         EXTERNAL DECLARATIONS
;********************************************************************************************************

                EXTERN  OSIntExit
                EXTERN  OSIntNesting
                EXTERN  OSTCBCur
                
                EXTERN  AppTickISR_Handler

;********************************************************************************************************
;                                          PUBLIC DECLARATIONS
;********************************************************************************************************

                PUBLIC  AppTickISR

;/*$PAGE*/
;********************************************************************************************************
;                                           SYSTEM TICK ISR
;
; Description : This function is the Tick ISR.
;
;               The following C-like pseudo-code describe the operation being performed in the code below.
;
;               Save all registers on the current task's stack:
;                      Use the PUSH_ALL macro
;                      Get the SREG, set Bit #7 and save onto the task's stack using -Y addressing
;                      Use the PUSH_SP macro to save the task's hardware stack pointer onto the current task's stack
;               OSIntNesting++;
;               if (OSIntNesting == 1) {
;                  OSTCBCur->OSTCBStkPtr = SP
;               }
;               Clear the interrupt;                  Not needed for the timer we used.
;               OSTimeTick();                         Notify uC/OS-II that a tick has occured
;               OSIntExit();                          Notify uC/OS-II about end of ISR
;               Restore all registers that were save on the current task's stack:
;                      Use the POP_SP macro to restore the task's hardware stack pointer
;                      Use the POP_SREG macro to restore the SREG register
;                      Use the POP_ALL macro to restore the remaining registers
;               Return from interrupt
;********************************************************************************************************

                RSEG FARCODE:CODE:NOROOT(1)
                
AppTickISR:
                PUSH_ALL                            ; Save all registers and status register
                IN      R16,SREG                    ; Save the SREG but with interrupts enabled
                SBR     R16,BIT07                    
                ST      -Y,R16
                PUSH_SP                             ; Save the task's hardware stack pointer onto task's stack

                LDS     R16,OSIntNesting            ; Notify uC/OS-II of ISR
                INC     R16                         ;
                STS     OSIntNesting,R16            ;

                CPI     R16,1                       ; if (OSIntNesting == 1) {
                BRNE    AppTickISR_1

                LDS     R30,OSTCBCur                ;     OSTCBCur->OSTCBStkPtr = Y
                LDS     R31,OSTCBCur+1
                ST      Z+,R28
                ST      Z+,R29                      ; }

AppTickISR_1:
                CALL    AppTickISR_Handler          ; Call tick ISR Handler written in C

                CALL    OSIntExit                   ; Notify uC/OS-II about end of ISR

                POP_SP                              ; Restore the hardware stack pointer from task's stack
                POP_SREG_INT
                POP_ALL                             ; Restore all registers
                RETI

                END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -