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

📄 dualadcint.asm

📁 Example_DUALADC_28pin CY3210-PSoCEVAL1 and CY3210-MiniEval1 Board Project
💻 ASM
📖 第 1 页 / 共 2 页
字号:
DUALADC_INT_CALCV1:
   mov   [(DUALADC_iResult1 + LowByte)],A                  ; Store LSB value
   mov   A, [DUALADC_cCounter1U]                           ; Store MSB from temp counter
   mov   [(DUALADC_iResult1 + HighByte)],A

   ; Get ADC2 result
   mov   A,reg[DUALADC_bCount2]                            ; Read counter value  (Bogus read puts value in Period register)
   mov   A,reg[DUALADC_bCompare2]                          ; Read counter value
   dec   A                                                 ; Decrement by one to make sure we didn't miss a count
   cpl   A                                                 ; Invert the value
   jnc   DUALADC_INT_CALCV2                                ; if carry, then inc MSB as well
   inc   [DUALADC_cCounter2U]
DUALADC_INT_CALCV2:
   mov   [(DUALADC_iResult2 + LowByte)],A                  ; Store LSB value
   mov   A, [DUALADC_cCounter2U]                           ; Store MSB from temp counter
   mov   [(DUALADC_iResult2 + HighByte)],A

                                                           ; The new value has been stored,
                                                           ; so get counters ready for next reading first.
   mov   reg[DUALADC_bPeriod1], ffh                        ; Initialize counter1 to FF - Set to overflow after 256 counts
   mov   reg[DUALADC_bPeriod2], ffh                        ; Initialize counter2 to FF - Set to overflow after 256 counts
   or    reg[DUALADC_bCounter1_CR0],DUALADC_fDBLK_ENABLE   ; Enable Counter1
   or    reg[DUALADC_bCounter2_CR0],DUALADC_fDBLK_ENABLE   ; Enable Counter2


IF (DUALADC_DATA_FORMAT)                                   ; Only check for Negative numbers if SIGNED result
   mov   A, [DUALADC_bfStatus]                             ; Get Status with Resolution
   and   A, DUALADC_bRES_MASK                              ; Mask of resolution
   index DUALADCMaxNegX4Table                              ; Get Maximum negative value from table
   mov   [DUALADC_cCounter1U], A                           ; Place result back into MSB of counter
   mov   [DUALADC_cCounter2U], A                           ; Place result back into MSB of counter
ELSE
   mov   [DUALADC_cCounter1U], 00h                         ; Place result back into MSB of counter
   mov   [DUALADC_cCounter2U], 00h                         ; Place result back into MSB of counter
ENDIF

   ;@PSoC_UserCode_BODY_3@ (Do not change this line.)
   ;---------------------------------------------------
   ; If the input is muxed with multiple inputs
   ; this is a good place to change inputs.
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers. At this
   ;   point A has been preserved on the stack and will
   ;   be restored before the return from interrupt.
   ;   However, if you use the X register, you must
   ;   preserve its value and restore it here.


   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

   and   reg[DUALADC_bfADC1cr3],~DUALADC_fFSW0             ; Take Integrator out of reset
   and   reg[DUALADC_bfADC2cr3],~DUALADC_fFSW0             ; Take Integrator out of reset
IF DUALADC_NoAZ
   and   reg[DUALADC_bfADC1cr2],~DUALADC_fAutoZero         ; Take Integrator out of AutoZero
   and   reg[DUALADC_bfADC2cr2],~DUALADC_fAutoZero         ; Take Integrator out of AutoZero
ENDIF

******************************

   ;****************************************************************************
   ;M8C_EnableGInt            ; May want to re-enable interrupts at this point,
   ;                          ; if stack space isn't at a premium.
   ; NOTE:  this will make system more responsive but, will increase the
   ;        overall processing time of the A/D calctime.  If an interrupt is
   ;        taken, it must return within the specified CalcTime to guarantee
   ;        successful acquisition of the next byte.
   ;****************************************************************************

; ADC1
IF (DUALADC_DATA_FORMAT)                         ; Only check for Negative numbers if SIGNED result
                                                 ; Negative Overflow Check
   tst   [(DUALADC_iResult1 + HighByte)],80h
   jnz   DUALADC_NOT_2POVFL1

ENDIF
                                                 ; Postive Overflow Check
                                                 ; Get MSB of Max Positive value x4 + 1
   mov   A,[DUALADC_bfStatus]                    ; Get Status with Resolution
   and   A,DUALADC_bRES_MASK                     ; Mask of resolution normalized to 0
   index DUALADCMaxPosX4Table                    ; Get Maximum positive value x4 + 1 from table
   push  A
   and   A, [(DUALADC_iResult1 + HighByte)]
   jz    DUALADC_NOT_POVFL1
                                                 ; Positive overflow, fix it - set to Max Positive + 1
   pop   A
   sub   A, 01h
                                                 ; Force most positive * 4 into result
   mov   [(DUALADC_iResult1 + HighByte)], A
   mov   [(DUALADC_iResult1 + LowByte)], ffh
   jmp   DUALADC_NOT_2POVFL1
DUALADC_NOT_POVFL1:
   pop   A

DUALADC_NOT_2POVFL1:
   asr   [(DUALADC_iResult1 + HighByte)]         ; Shift MSB and LSB right twice to divide by four
   rrc   [(DUALADC_iResult1 + LowByte)]          ; Remember digital clock 4 times analog clock
   asr   [(DUALADC_iResult1 + HighByte)]
   rrc   [(DUALADC_iResult1 + LowByte)]

; ADC2
IF (DUALADC_DATA_FORMAT)                         ; Only check for Negative numbers if SIGNED result
                                                 ; Negative Overflow Check
   tst   [(DUALADC_iResult2 + HighByte)],80h
   jnz   DUALADC_NOT_2POVFL2

ENDIF
                                                 ; Postive Overflow Check
                                                 ; Get MSB of Max Positive value x4 + 1
   mov   A,[DUALADC_bfStatus]                    ; Get Status with Resolution
   and   A,DUALADC_bRES_MASK                     ; Mask of resolution normalized to 0
   index DUALADCMaxPosX4Table                    ; Get Maximum positive value x4 + 1 from table
   push  A
   and   A, [(DUALADC_iResult2 + HighByte)]
   jz    DUALADC_NOT_POVFL2
                                                 ; Positive overflow, fix it - set to Max Positive + 1
   pop   A
   sub   A, 01h
                                                 ; Force most positive * 4 into result
   mov   [(DUALADC_iResult2 + HighByte)], A
   mov   [(DUALADC_iResult2 + LowByte)], ffh
   jmp   DUALADC_NOT_2POVFL2
DUALADC_NOT_POVFL2:
   pop   A

DUALADC_NOT_2POVFL2:
   asr   [(DUALADC_iResult2 + HighByte)]         ; Shift MSB and LSB right twice to divide by four
   rrc   [(DUALADC_iResult2 + LowByte)]          ; Remember digital clock 4 times analog clock
   asr   [(DUALADC_iResult2 + HighByte)]
   rrc   [(DUALADC_iResult2 + LowByte)]

   ;**********************************************
   ; Data is ready at this point.
   ; If processing Data at Interrupt level - add
   ;     User Code to handle the data
   ;**********************************************
   ;@PSoC_UserCode_BODY_4@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers. At this
   ;   point A has been preserved on the stack and wil
   ;   be restored later. However, if you use X, be
   ;   sure to take care of it yourself!


   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

   pop   A                                       ; Restore A, not used any more

   or    [DUALADC_bfStatus],DUALADC_fDATA_READY  ; Set Data ready bit

   tst   [DUALADC_bSampC], ffh                   ; If sample_counter == 0 -->> continuous data collection
   jz    DUALADC_END_PWM16_ISR

   dec   [DUALADC_bSampC]                        ; Dec sample counter and check for zero
   jnz   DUALADC_END_PWM16_ISR

   and   reg[DUALADC_fPWM_LSB_CR0], ~DUALADC_fDBLK_ENABLE      ; Disable the PWM

   and   reg[DUALADC_bCounter1_CR0], ~DUALADC_fDBLK_ENABLE           ; Disable the Counter
   and   reg[DUALADC_bCounter2_CR0], ~DUALADC_fDBLK_ENABLE           ; Disable the Counter

IF DUALADC_NoAZ
   or    reg[DUALADC_bfADC1cr2], DUALADC_fAutoZero             ; Put the Integrator into Autozero mode
   or    reg[DUALADC_bfADC2cr2], DUALADC_fAutoZero             ; Put the Integrator into Autozero mode
ENDIF

   or    reg[DUALADC_bfADC1cr3], DUALADC_fFSW0                 ; Put Integrator into reset
   or    reg[DUALADC_bfADC2cr3], DUALADC_fFSW0                 ; Put Integrator into reset

   and   reg[DUALADC_bfPWM16_INT_REG], ~DUALADC_bfPWM16_Mask      ; Disable interrupts
   and   reg[DUALADC_bfCounter1_INT_REG], ~DUALADC_bfCounter1_Mask
   and   reg[DUALADC_bfCounter2_INT_REG], ~DUALADC_bfCounter2_Mask

DUALADC_END_PWM16_ISR:
   reti

DUALADC_APIINT_END:

⌨️ 快捷键说明

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