📄 adcint.lis
字号:
0000 .LITERAL
0000 ADCMaxNegX4Table:
0000 ; Bits 7 8 9 10 11 12 13
0000 FFFEFCF8F0E0C0 DB FFh, FEh, FCh, F8h, F0h, E0h, C0h
0007
0007 ADCMaxPosX4Table:
IF (ADC_DATA_FORMAT)
; Bits (signed) 7 8 9 10 11 12 13
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h
ELSE
; Bits (unsigned) 7 8 9 10 11 12 13
0007 02040810204080 DB 02h, 04h, 08h, 10h, 20h, 40h, 80h
000E
ENDIF
000E .ENDLITERAL
000E
000E ;-----------------------------------------------------------------------------
000E ; FUNCTION NAME: _ADC_CNT_ISR (Counter8 Interrupt)
000E ;
000E ;
000E ; DESCRIPTION:
000E ; Increment the upper (software) half on the counter whenever the
000E ; lower (hardware) half of the counter underflows. This counter
000E ; should start out at the most negative value (0xFF).
000E ;
000E ;-----------------------------------------------------------------------------
000E ;
000E _ADC_CNT_ISR:
000E 7600 inc [ADC_cCounterU]
0010 ;@PSoC_UserCode_BODY_1@ (Do not change this line.)
0010 ;---------------------------------------------------
0010 ; Insert your custom code below this banner
0010 ;---------------------------------------------------
0010
0010 ;---------------------------------------------------
0010 ; Insert your custom code above this banner
0010 ;---------------------------------------------------
0010 ;@PSoC_UserCode_END@ (Do not change this line.)
0010 7E reti
0011
0011
0011 ;-----------------------------------------------------------------------------
0011 ; FUNCTION NAME: _ADC_PWM16_ISR (PWM16 Interrupt)
0011 ;
0011 ; DESCRIPTION:
0011 ; This ISR is called when the ADC has completed and integrate cycle.
0011 ; The ADC value is calculated and stored in a global location before
0011 ; the end of the ISR.
0011 ;
0011 ;-----------------------------------------------------------------------------
0011 ;
0011 _ADC_PWM16_ISR:
0011 412FFE and reg[ADC_bCounter_CR0], ~ADC_fDBLK_ENABLE ; Disable Counter
IF ADC_NoAZ
0014 438620 or reg[ADC_bfAtoDcr2], ADC_fAutoZero ; Put Integrator in AutoZero
ENDIF
0017 438710 or reg[ADC_bfAtoDcr3],ADC_fFSW0 ; Put Integrator in reset
001A
001A ; Enable interrupts for a short period of time just in case.
001A ; Make sure we didn't have a counter interrupt ready to fire
001A 7101 or F, FLAG_GLOBAL_IE
001C 40 nop ; Wait a couple cycles
001D 70FE and F, ~FLAG_GLOBAL_IE
001F 08 push A ; Save the Accumulator
0020 5D2C mov A,reg[ADC_bCount] ; Read counter value (Bogus read puts value in Period register)
0022 5D2E mov A,reg[ADC_bCompare] ; Read counter value
0024 78 dec A ; Decrement by one to make sure we didn't miss a count
0025 73 cpl A ; Invert the value
0026 D003 jnc ADC_INT_CALCV ; if carry, then inc MSB as well
0028 7600 inc [ADC_cCounterU]
002A ADC_INT_CALCV:
002A 5302 mov [(ADC_iResult + LowByte)], A ; Store LSB value
002C 5100 mov A, [ADC_cCounterU] ; Store MSB from temp counter
002E 5301 mov [(ADC_iResult + HighByte)], A
0030 ; The new value has been stored,
0030 ; so get counters ready for next reading first.
0030 622DFF mov reg[ADC_bPeriod], ffh ; Initialize counter to FF - Set to overflow after 256 counts
0033 432F01 or reg[ADC_bCounter_CR0],ADC_fDBLK_ENABLE ; Enable Counter
0036
IF (ADC_DATA_FORMAT) ; Only check for Negative numbers if SIGNED result
mov A, [ADC_bfStatus] ; Get Status with Resolution
and A, ADC_bRES_MASK ; Mask of resolution
index ADCMaxNegX4Table ; Get Maximum negative value from table
mov [ADC_cCounterU], A ; Place result back into MSB of counter
ELSE
0036 550000 mov [ADC_cCounterU], 00h ; Place result back into MSB of counter
ENDIF
;@PSoC_UserCode_BODY_2@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom code below this banner
;---------------------------------------------------
;---------------------------------------------------
; Insert your custom code above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
0039 4187EF and reg[ADC_bfAtoDcr3],~ADC_fFSW0 ; Take Integrator out of reset
IF ADC_NoAZ
003C 4186DF and reg[ADC_bfAtoDcr2],~ADC_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.
;****************************************************************************
IF (ADC_DATA_FORMAT) ; Only check for Negative numbers if SIGNED result
; Negative Overflow Check
tst [(ADC_iResult + HighByte)],80h
jnz ADC_NOT_POVFL2
ENDIF
; Postive Overflow Check
; Get MSB of Max Positive value x4 + 1
003F 5103 mov A,[ADC_bfStatus] ; Get Status with Resolution
0041 210F and A,ADC_bRES_MASK ; Mask of resolution normalized to 0
0043 FFC2 index ADCMaxPosX4Table ; Get Maximum positive value x4 + 1 from table
0045 08 push A
0046 2201 and A, [(ADC_iResult + HighByte)]
0048 A00B jz ADC_NOT_POVFL
004A ; Positive overflow, fix it - set to Max Positive + 1
004A 18 pop A
004B 1101 sub A, 01h
004D
004D ; Force most positive * 4 into result
004D 5301 mov [(ADC_iResult + HighByte)], A
004F 5502FF mov [(ADC_iResult + LowByte)], ffh
0052 8002 jmp ADC_NOT_POVFL2
0054 ADC_NOT_POVFL:
0054 18 pop A
0055
0055 ADC_NOT_POVFL2:
0055 6801 asr [(ADC_iResult + HighByte)] ; Shift MSB and LSB right twice to divide by four
0057 6E02 rrc [(ADC_iResult + LowByte)] ; Remember digital clock 4 times analog clock
0059 6801 asr [(ADC_iResult + HighByte)]
005B 6E02 rrc [(ADC_iResult + LowByte)]
005D
005D ;@PSoC_UserCode_BODY_3@ (Do not change this line.)
005D ;---------------------------------------------------
005D ; Insert your custom code below this banner
005D ;---------------------------------------------------
005D 43DE80 or reg[INT_MSK3], 80h
0060 43DD01 or reg[INT_CLR3], 01h
0063 41DE7F and reg[INT_MSK3], ~80h
0066 ;---------------------------------------------------
0066 ; Insert your custom code above this banner
0066 ;---------------------------------------------------
0066 ;@PSoC_UserCode_END@ (Do not change this line.)
0066
0066 18 pop A ; Restore A, not used any more
0067
0067 2E0310 or [ADC_bfStatus],ADC_fDATA_READY ; Set Data ready bit
006A
006A 4704FF tst [ADC_bSampC], ffh ; If sample_counter == 0 -->> continuous data collection
006D A017 jz ADC_END_PWM16_ISR
006F
006F 7A04 dec [ADC_bSampC] ; Dec sample counter and check for zero
0071 B013 jnz ADC_END_PWM16_ISR
0073
0073 ;**********************************************
0073 ; Turn off ADC
0073 ;**********************************************
0073 4127FE and reg[ADC_fPWM_LSB_CR0], ~ADC_fDBLK_ENABLE ; Disable the PWM
0076 412FFE and reg[ADC_bCounter_CR0], ~ADC_fDBLK_ENABLE ; Disable the Counter
IF ADC_NoAZ
0079 438620 or reg[ADC_bfAtoDcr2], ADC_fAutoZero ; Put the Integrator into Autozero mode
ENDIF
007C 438710 or reg[ADC_bfAtoDcr3], ADC_fFSW0 ; Put Integrator into reset
007F 41E1FB and reg[ADC_bfPWM16_INT_REG], ~ADC_bfPWM16_Mask ; Disable interrupts
0082 41E1F7 and reg[ADC_bfCounter_INT_REG], ~ADC_bfCounter_Mask
0085
0085 ADC_END_PWM16_ISR:
0085 7E reti
0086
0086 ; End of File ADCINT.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -