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

📄 isr.s03

📁 embed in keil
💻 S03
📖 第 1 页 / 共 2 页
字号:
;----------------------------------------------------------------------------------------+
;                                                                                        |
;                               INTERRUPT SERVICE ROUTINES                               |
;                                                                                        |
;  Filename    :  isr.s03                                                                |
;                                                                                        |
;  Description :  This file contains the assembly language code that implements the      |
;                 interrupt service routines that need low-level handling.               |
;                                                                                        |
;  Author      :  Antonio Fuentes (antonio_fuentes@msl-vlc.com)                          |
;                                                                                        |
;  Date        :  October 24, 2001                                                       |
;----------------------------------------------------------------------------------------+
         NAME     INIT              ;Module name
         ASEG                       ;Absolute Segment
         COMMON   INTVEC(0)         ;Shares interrupt vectors space

;<---[ "Include" files: ]---------------------------------------------------------------->

$sfr8052.inc                        ;Generic defines for the 8052 chip derivatives
$brd_defs.inc                       ;Specific defines for the processor board

 ;<---[ References external to this module: ]-------------------------------------------->

         EXTERN   init_C            ;Address of initialization code (IAR Systems-specific)
         EXTERN   OSTickIsr         ;Timer #0 ISR (system tick for uC/OS-II)
         EXTERN   Serial            ;On-chip RS232 Serial Port service routine

;<--------------------------------- Beginning of code: ---------------------------------->

         org     0000h              ;Reset vector: 0000H
         jmp     init_C             ;Skip over interrupt vectors

;+---------------------------------------------------------------------------------------+
;  Interrupt Vector Table:                                                               |
;+---------------------------------------------------------------------------------------+

;<---[ INT0 Interrupt Vector: ]---------------------------------------------------------->

         org     0003h
         reti    

;<---[ TIMER#0 Interrupt Vector: ]------------------------------------------------------->

         org     000Bh
         jmp     OSTickIsr

; This is the system 'tick' used by uC/OS-II to synchronise events and manage the whole
; system activity.

;<---[ INT1 Interrupt Vector: ]---------------------------------------------------------->

         org     0013H
         reti

;<---[ TIMER#1 Interrupt Vector: ]------------------------------------------------------->

         org     001Bh
         reti

;<---[ Serial Interrupt Vector: ]-------------------------------------------------------->

         org     0023h
         jmp     Serial

; This is the on-chip serial port interrupt service. This interrupt is always
; enabled to allow the Operating System to communicate with the outside world.

;<---[ TIMER#2 Interrupt Vector: ]------------------------------------------------------>

         org     002Bh
         reti

; This interrupt is not available, as Timer #2 is used as a baud-rate generator
; for the on-chip serial port (native serial port).

;<---[ Microcode Signature: ]------------------------------------------------------------>

         org    0060h

         db     '<< uC/OS-II V2.51 Test Board - November, 2001 >>'

         ENDMOD                      ; End of this module 
;----------------------------------------------------------------------------------------+
;                                HANDLE THE SYSTEM TICK                                  |
; void OSTickIsr(void)                                                                   |
;                                                                                        |
; Timer #0 Interrupt Service Routine                                                     |
;----------------------------------------------------------------------------------------+
         MODULE   OSTICKISR         ;Module name
         RSEG     CODE              ;Relocatable Segment

;<---[ Symbols available for other modules: ]-------------------------------------------->

         PUBLIC   OSTickIsr         ;Timer #0 ISR (system tick)
         
;<---[ Symbols referenced, in other modules: ]------------------------------------------->

         EXTERN   OSTimeTick        ;Module: Process system 'tick'
         EXTERN   OSIntEnter        ;Module: Notify OS that interrupt is being serviced
         EXTERN   OSIntExit         ;Module: Notify OS that interrupt is being exited
;<--------------------------------------------------------------------------------------->
OSTickIsr:                          ;Module entry point
 
         push    PSW                        ;Save PSW
         push    ACC                        ;Save accumulator
         push    b                          ;Save B register
         push    Bk0_r0                     ;Save Bank #0 R0
         push    Bk0_r1                     ;Save Bank #0 R1
         push    Bk0_r2                     ;Save Bank #0 R2
         push    Bk0_r3                     ;Save Bank #0 R3
         push    Bk0_r4                     ;Save Bank #0 R4
         push    Bk0_r5                     ;Save Bank #0 R5
         push    Bk0_r6                     ;Save Bank #0 R6
         push    Bk0_r7                     ;Save Bank #0 R7
         push    DPH                        ;Save Pointer high
         push    DPL                        ;Save Pointer low
         push    XSP                        ;Save xstack base pointer high
         push    XSP+1                      ;Save xstack base pointer low

         mov     TL0, TL0_BUFF              ;LSB reload value set by user
         mov     TH0, TH0_BUFF              ;MSB reload value set by user                                    
         
         lcall   OSIntEnter                 ;Read-modify-write increment of "OSIntNesting"
         lcall   OSTimeTick                 ;Call process
         lcall   OSIntExit                  ;Decrement OSIntNesting, and determine whether a
                                            ;..context switch needs to take place
         pop     XSP+1                      ;Restore xstack base pointer low
         pop     XSP                        ;Restore xstack base pointer high
         pop     DPL                        ;Restore pointer low
         pop     DPH                        ;Restore pointer high
         pop     Bk0_r7                     ;Restore Bank #0 R7
         pop     Bk0_r6                     ;Restore Bank #0 R6
         pop     Bk0_r5                     ;Restore Bank #0 R5
         pop     Bk0_r4                     ;Restore Bank #0 R4
         pop     Bk0_r3                     ;Restore Bank #0 R3
         pop     Bk0_r2                     ;Restore Bank #0 R2
         pop     Bk0_r1                     ;Restore Bank #0 R1
         pop     Bk0_r0                     ;Restore Bank #0 R0    
         pop     b                          ;Restore register B
         pop     ACC                        ;Restore accumulator
         pop     PSW                        ;Restore PSW
         reti                               ;Jump to execute scheduled task

         ENDMOD
;----------------------------------------------------------------------------------------+

⌨️ 快捷键说明

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