谢谢你。这是源于TI的例程。但似乎例程在运行上没有什么问题啊?是不是我挪去这个>>也是OK的呢?
源程序这里是用汇编处理ADC采样结果,全段如下。但似乎这种MOVW DP #xx >>6 使用了很多次。有没有可能是通用的呢?谢谢哦
_ISR_Run: ;(13 cycles to get to here from ISR trigger)
;CONTEXT_SAVE
PUSH AR1H:AR0H ; 32-bit
PUSH XAR2 ; 32-bit
PUSH XAR3 ; 32-bit
PUSH XAR4 ; 32-bit
;----------------------------------------
PUSH XT ; 32-bit
NOP
;---------------------------------------------------------
MOVW DP,#ADCST>>6 ; Make sure ADC conversion has completed
ADC_Conv:
MOV AL,@ADCST ; check seq1 busy bit
AND AL,#0x0004 ; This code may not be needed with proper timing
B ADC_Conv, NEQ ; and buffer code that doesn't use the ADC result and
; runs from the start of the ISR till the completion of ADC conversion
ADC_NchDRV 3 ; 3 Channel, (i.e. N=3)
ADC_Reset:
MOVW DP,#ADCTRL2>>6 ; Reset ADC SEQ
MOV @ADCTRL2,#0x4100 ; RST_SEQ1=1, SOCA-SEQ1=1
; ADC Sample Point Calculation
MOVW DP,#TBPHS3>>6
MOV AL,@TBPHS3 ; TBPHS3
ADD AL,@TBPRD3 ; TBPRD3
LSR AL,#1 ; ACC = (TBPRD3 + TBPHS3)/2
MOV @CMPB3, AL ; CMPB3 = (TBPRD3 + TBPHS3)/2
;---------------------------------------------------------
; Datalog to store and plot upto four variables in the control flow
MOVW DP,#dlog_cntr
INC @dlog_cntr
CMP @dlog_cntr,#4
B EXIT_ISR, LT ; Execute this module 4x slower
MOV @dlog_cntr,#0 ; Reset loop counter
DLOG_4CH_update
EXIT_ISR:
;===================================
MOVW DP,#PIEACK>>6 ; Acknowledge PIE interrupt Group 3
MOV @PIEACK,#PIEACK_GROUP3
.endif ; EPWMn_ISR
.if(ADC_ISR)
; Case where ISR is triggered by ADC
MOVW DP,#ADCST>>6
MOV @ADCST,#0x010 ; Clear INT SEQ1 Int flag
MOVW DP,#PIEACK>>6 ; Acknowledge PIE interrupt Group 1
MOV @PIEACK,#PIEACK_GROUP1
.endif ; ADC_ISR
; Restore context & return
POP XT
;-----------------------------------
POP XAR4
POP XAR3
POP XAR2
POP AR1H:AR0H
IRET
谢谢你。这是源于TI的例程。但似乎例程在运行上没有什么问题啊?是不是我挪去这个>>也是OK的呢?
源程序这里是用汇编处理ADC采样结果,全段如下。但似乎这种MOVW DP #xx >>6 使用了很多次。有没有可能是通用的呢?谢谢哦
_ISR_Run: ;(13 cycles to get to here from ISR trigger)
;CONTEXT_SAVE
PUSH AR1H:AR0H ; 32-bit
PUSH XAR2 ; 32-bit
PUSH XAR3 ; 32-bit
PUSH XAR4 ; 32-bit
;----------------------------------------
PUSH XT ; 32-bit
NOP
;---------------------------------------------------------
MOVW DP,#ADCST>>6 ; Make sure ADC conversion has completed
ADC_Conv:
MOV AL,@ADCST ; check seq1 busy bit
AND AL,#0x0004 ; This code may not be needed with proper timing
B ADC_Conv, NEQ ; and buffer code that doesn't use the ADC result and
; runs from the start of the ISR till the completion of ADC conversion
ADC_NchDRV 3 ; 3 Channel, (i.e. N=3)
ADC_Reset:
MOVW DP,#ADCTRL2>>6 ; Reset ADC SEQ
MOV @ADCTRL2,#0x4100 ; RST_SEQ1=1, SOCA-SEQ1=1
; ADC Sample Point Calculation
MOVW DP,#TBPHS3>>6
MOV AL,@TBPHS3 ; TBPHS3
ADD AL,@TBPRD3 ; TBPRD3
LSR AL,#1 ; ACC = (TBPRD3 + TBPHS3)/2
MOV @CMPB3, AL ; CMPB3 = (TBPRD3 + TBPHS3)/2
;---------------------------------------------------------
; Datalog to store and plot upto four variables in the control flow
MOVW DP,#dlog_cntr
INC @dlog_cntr
CMP @dlog_cntr,#4
B EXIT_ISR, LT ; Execute this module 4x slower
MOV @dlog_cntr,#0 ; Reset loop counter
DLOG_4CH_update
EXIT_ISR:
;===================================
MOVW DP,#PIEACK>>6 ; Acknowledge PIE interrupt Group 3
MOV @PIEACK,#PIEACK_GROUP3
.endif ; EPWMn_ISR
.if(ADC_ISR)
; Case where ISR is triggered by ADC
MOVW DP,#ADCST>>6
MOV @ADCST,#0x010 ; Clear INT SEQ1 Int flag
MOVW DP,#PIEACK>>6 ; Acknowledge PIE interrupt Group 1
MOV @PIEACK,#PIEACK_GROUP1
.endif ; ADC_ISR
; Restore context & return
POP XT
;-----------------------------------
POP XAR4
POP XAR3
POP XAR2
POP AR1H:AR0H
IRET
举报