📄 lab4.lst
字号:
0420 009F 00013 movwf ADCON1 ; channel 0 (RA0), all other pins are digital mode
0421 1283 1303 00014 BANKSEL ADCON0 ; BANKSEL to ADCON0 in bank 0
0423 3041 00015 movlw H'41' ; Also, A/D clock is Fosc/8 (good for up to 5 MHz, 5V) and,
0424 009F 00016 movwf ADCON0 ; A/D is turned on but not yet converting and ready on Ch 0.
00017
00018 PiezoEnable 440
0425 1683 1303 M BANKSEL TRISC
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0427 1107 M bcf TRISC,2
0428 3038 M movlw ((DEVICE_FREQ_HZ/D'64')/440)-1
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0429 0092 M movwf PR2
042A 301C M movlw ((DEVICE_FREQ_HZ/D'128')/440)
042B 1283 1303 M BANKSEL CCPR1L
042D 0095 M movwf CCPR1L
042E 3006 M movlw 0x06 ; Turn on TMR2 (for PWM)
042F 0092 M movwf T2CON ; and /16 prescale
0430 00019 CheckAgain
00020 Dly32 D'50' ; MACRO to Wait 1 ms (at 4 MHz)
M
0430 1283 1303 M BANKSEL Dly3
0432 3031 M movlw (D'50'-1) & H'FF' ; * Take the delay value argument
0433 00A0 M movwf Dly0 ; * from the macro, precalculate
0434 3000 M movlw (D'50'-1) >>D'08' & H'FF' ; * the required 4 RAM values and
0435 00A1 M movwf Dly1 ; * load the The RAM values Dly3
0436 3000 M movlw (D'50'-1) >>D'16' & H'FF' ; * though Dly0.
0437 00A2 M movwf Dly2 ; * Bytes are shifted and anded
MPASM 5.02 LAB4.ASM 8-11-2006 13:39:24 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0438 3000 M movlw (D'50'-1) >>D'24' & H'FF' ; * by the assembler to make
0439 00A3 M movwf Dly3 ; * user calculations easier
M
043A 0000 M nop ; 7 cycle delay for precision delay value
043B 0000 M nop ;
043C 0000 M nop ;
043D 0000 M nop ;
043E 0000 M nop ;
043F 0000 M nop ;
0440 0000 M nop ;
M
0441 2401 M call DoDly32 ; Call DoDly32 to run the delay loop.
0442 151F 00021 bsf ADCON0,GO ; Start the Conversion
00022
0443 00023 PollAD
0443 191F 00024 btfsc ADCON0,GO ; Wait for Conversion to finish
0444 2C43 00025 goto PollAD ; go back and poll the A/D GO/DONE bit again
0445 00026 ConvertDone
0445 081E 00027 movf ADRESH,W ; Move A/D result (high byte) into W for later testing
0446 3C64 00028 sublw TESTVAL ; Test A/D result against test value
0447 1C03 00029 btfss STATUS,C ; go to "over" if A/D result larger than test value
0448 2C4F 00030 goto Over ; value is too large, run "Over" code
0449 00031 Ok
00032 LEDOn 0 ; MACRO to turn on LED 0
0449 3001 M movlw 1 << 0
044A 0486 M iorwf PORTB,F
00033 LEDOff 1 ; MACRO to turn off LED 1 (this shows "Ok" condition)
044B 30FD M movlw H'FF' - ((1 << 1) & H'00FF')
044C 0586 M andwf PORTB,F
00034 PiezoOff
044D 0197 M clrf CCP1CON
044E 2C30 00035 goto CheckAgain ; Do A/D read and value test over again
044F 00036 Over
00037 LEDOn 1 ; MACRO to turn on LED 1
044F 3002 M movlw 1 << 1
0450 0486 M iorwf PORTB,F
00038 LEDOff 0 ; MACRO to turn off LED 0 (this shows "Over" condition)
0451 30FE M movlw H'FF' - ((1 << 0) & H'00FF')
0452 0586 M andwf PORTB,F
00039 PiezoOn
0453 300C M movlw H'0C'
0454 0097 M movwf CCP1CON
0455 2C30 00040 goto CheckAgain ; Do A/D read and value test over again
00041 END
MPASM 5.02 LAB4.ASM 8-11-2006 13:39:24 PAGE 6
SYMBOL TABLE
LABEL VALUE
ACKDT 00000005
ACKEN 00000004
ACKSTAT 00000006
ADCON0 0000001F
ADCON1 0000009F
ADCS0 00000006
ADCS1 00000007
ADCS2 00000006
ADDEN 00000003
ADFM 00000007
ADIE 00000006
ADIF 00000006
ADON 00000000
ADRESH 0000001E
ADRESL 0000009E
BCLIE 00000003
BCLIF 00000003
BF 00000000
BRGH 00000002
C 00000000
C1INV 00000004
C1OUT 00000006
C2INV 00000005
C2OUT 00000007
CCP1CON 00000017
CCP1IE 00000002
CCP1IF 00000002
CCP1M0 00000000
CCP1M1 00000001
CCP1M2 00000002
CCP1M3 00000003
CCP1X 00000005
CCP1Y 00000004
CCP2CON 0000001D
CCP2IE 00000000
CCP2IF 00000000
CCP2M0 00000000
CCP2M1 00000001
CCP2M2 00000002
CCP2M3 00000003
CCP2X 00000005
CCP2Y 00000004
CCPR1H 00000016
CCPR1L 00000015
CCPR2H 0000001C
CCPR2L 0000001B
CHS0 00000003
CHS1 00000004
CHS2 00000005
CIS 00000003
CKE 00000006
CKP 00000004
CM0 00000000
MPASM 5.02 LAB4.ASM 8-11-2006 13:39:24 PAGE 7
SYMBOL TABLE
LABEL VALUE
CM1 00000001
CM2 00000002
CMCON 0000009C
CMIE 00000006
CMIF 00000006
CREN 00000004
CSRC 00000007
CVR0 00000000
CVR1 00000001
CVR2 00000002
CVR3 00000003
CVRCON 0000009D
CVREN 00000007
CVROE 00000006
CVRR 00000005
CheckAgain 00000430
ConvertDone 00000445
D 00000005
DATA_ADDRESS 00000005
DC 00000001
DEVICE_FREQ_HZ D'4000000'
D_A 00000005
Dly0 00000020
Dly1 00000021
Dly2 00000022
Dly3 00000023
Dly32
DoDly32 00000401
EEADR 0000010D
EEADRH 0000010F
EECON1 0000018C
EECON2 0000018D
EEDATA 0000010C
EEDATH 0000010E
EEIE 00000004
EEIF 00000004
EEPGD 00000007
F 00000001
FERR 00000002
FSR 00000004
GCEN 00000007
GIE 00000007
GO 00000002
GO_DONE 00000002
I2C_DATA 00000005
I2C_READ 00000002
I2C_START 00000003
I2C_STOP 00000004
IBF 00000007
IBOV 00000005
INDF 00000000
INTCON 0000000B
INTE 00000004
MPASM 5.02 LAB4.ASM 8-11-2006 13:39:24 PAGE 8
SYMBOL TABLE
LABEL VALUE
INTEDG 00000006
INTF 00000001
IRP 00000007
ISRRestore
ISRSave
LEDEnable
LEDOff
LEDOn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -