|
在arm7+uCOS平台,在某些应用场合中,可能会有这样一种中断: 发生的频率很高,但是中断服务很简单,我称之为“轻量级中断”,具体举例来说,比如毫秒中断,1毫秒发生1次,中断服务中,只对某个变量进行累加(此变量可能不是很重要)。此时,我觉得没有必要进行任务的调度,因为太过于频繁的任务调度会消耗掉不少CPU资源。
请教一下专家:
不知,我这个思路是否可行?如果可行,应该如何去修改OS_INT_A.S这个代码呢?谢谢!
PRESERVE8
AREA UCOS_ARM_ASM_INT,CODE,READONLY
;*********************************************************************************************************
; IRQ HANDLER
;
; This handles all the IRQs
; Note: FIQ Handler should be written similar to this
;
;*********************************************************************************************************
;In μC/OS-II, ISRs includes several parts: save CPU registers, call function OSIntEnter(),
;execute user code, call function OSIntExit(), restore CPU registers and return.
;Function OSIntEnter() is used to notify μC/OS-II that you are about to service an interrupt (ISR)
;and function OSIntExit() is used to notify μC/OS-II that you have completed serving an ISR.
;With OSIntEnter() and OSIntExit(), μC/OS-II can keep track of interrupt nesting and thus only perform rescheduling at the last nested ISR.
;Sometime when the last nested ISR is completed, the interrupted task will be no longer the task that needs to run because a new,
; higher-priority task is now ready. In this case, interrupt level context switch is needed. This is done by function _IntCtxSw().
; Then after return, the new, higher-priority task is running and the old one is pending.
;These codes should be written in assembly language because you cannot access CPU registers directly from C.
; But user code can be written in C. Here we use macro code to implement ISR in file irq_handler.s.
; The code can be shown as following and should be duplicated for each ISR you have in your system.
IMPORT OSIntEnter
IMPORT OSIntExit
IMPORT OSIntCtxSwFlag
IMPORT _IntCtxSw
MACRO
$IRQ_AsmEntery HANDLER $IRQ_CEntry
EXPORT $IRQ_AsmEntery
IMPORT $IRQ_CEntry
$IRQ_AsmEntery STMFD SP!,{R0-R3,R12,LR} ; Protects the task environments 保存任务环境
BL OSIntEnter ; Interrupt Nest++
BL $IRQ_CEntry ; User ISR Subroutine
BL OSIntExit
LDR R0,=OSIntCtxSwFlag
LDR R1,[R0]
CMP R1,#1
BEQ _IntCtxSw ; interrupt level context switch
LDMFD SP!,{R0-R3,R12,LR}
SUBS PC,LR,#4 ; return
MEND
IRQASMTimer0 HANDLER IRQCTimer0
IRQASMTimer1 HANDLER IRQCTimer1
IRQASMUart0 HANDLER uart0Isr
;IRQASMUart3 HANDLER uart3Isr
IRQASMi2c0 HANDLER i2c0IRQ
IRQ_Handler HANDLER IRQ_Exception
END |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|