📄 base1.lst
字号:
00D7 3001 00095 MOVLW 0x01 ; Code to clear display
00D8 20B5 00096 CALL send ; and send code
00D9 3006 00097 MOVLW 0x06 ; Enable cursor auto inc
00DA 20B5 00098 CALL send ; and send code
00DB 3080 00099 MOVLW 0x80 ; Zero display address
00DC 20B5 00100 CALL send ; and send code
00DD 300C 00101 MOVLW 0x0C ; Turn on display
00DE 20B5 00102 CALL send ; and send code
00103
00DF 0008 00104 RETURN ; Done
MPASM 03.70.01 Released BASE1.ASM 3-28-2006 19:32:15 PAGE 9
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00105 ;------------------------------------------------------------
00297 ;
00298 ;----------------------------------------------------------
00299 ; Convert 8 bits to 3 digit decimal
00300 ;
00301 ; Receives 8-bits in W
00302 ; Returns BCD diits in 'huns','tens','ones'
00303 ;
00304 INCLUDE "CONDEC.INC";
00001 ;
00002 ;-----------------------------------------------------------
00003 ; CONDEC.INC MPB 1-7-05
00004 ; Converts 8-bit binary to decimal
00005 ; Returns digits in Huns, Tens, Ones registers
00006 ;-----------------------------------------------------------
00007
00000077 00008 ADbin EQU 77 ; Binary input value
00000078 00009 Huns EQU 78 ; Hundreds digit in decimal value
00000079 00010 Tens EQU 79 ; Tens digit in decimal value
0000007A 00011 Ones EQU 7A ; Ones digit in decimal value
00012
00013 ;-----------------------------------------------------------
00014 ; Convert input to decimal
00015
00E0 00F7 00016 condec MOVWF ADbin ; get ADC result
00E1 01F8 00017 CLRF Huns ; zero hundreds digit
00E2 01F9 00018 CLRF Tens ; zero Tens digit
00E3 01FA 00019 CLRF Ones ; zero Ones digit
00020
00021 ; Calclulate hundreds.......................................
00022
00E4 1403 00023 BSF STATUS,C ; set carry for subtract
00E5 3064 00024 MOVLW D'100' ; load 100
Message[305]: Using default destination of 1 (file).
00E6 02F7 00025 sub1 SUBWF ADbin ; and subtract from result
Message[305]: Using default destination of 1 (file).
00E7 0AF8 00026 INCF Huns ; count number of loops
00E8 1803 00027 BTFSC STATUS,C ; and check if done
00E9 28E6 00028 GOTO sub1 ; no, carry on
00029
Message[305]: Using default destination of 1 (file).
00EA 07F7 00030 ADDWF ADbin ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
00EB 03F8 00031 DECF Huns ; and correct loop count
00032
00033 ; Calculate Tens digit......................................
00034
00EC 1403 00035 BSF STATUS,C ; repeat process for Tens
00ED 300A 00036 MOVLW D'10' ; load 10
Message[305]: Using default destination of 1 (file).
00EE 02F7 00037 sub2 SUBWF ADbin ; and subtract from result
Message[305]: Using default destination of 1 (file).
00EF 0AF9 00038 INCF Tens ; count number of loops
MPASM 03.70.01 Released BASE1.ASM 3-28-2006 19:32:15 PAGE 10
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00F0 1803 00039 BTFSC STATUS,C ; and check if done
00F1 28EE 00040 GOTO sub2 ; no, carry on
00041
Message[305]: Using default destination of 1 (file).
00F2 07F7 00042 ADDWF ADbin ; yes, add 100 back on
Message[305]: Using default destination of 1 (file).
00F3 03F9 00043 DECF Tens ; and correct loop count
00F4 0877 00044 MOVF ADbin,W ; load remainder
00F5 00FA 00045 MOVWF Ones ; and store as Ones digit
00046
00F6 0008 00047 RETURN ; done
00305 ;
00306 ;----------------------------------------------------------
00307 ; Read selected analogue input
00308 ;
00309 ; Receives channel number in W
00310 ; Returns 8-bit input in W
00311 ;
00312 INCLUDE "ADIN.INC"
00001 ;
00002 ;-----------------------------------------------------------
00003 ; ADIN.INC MPB 10-1-06
00004 ; Include file to read analogue input
00005 ; Receives channel selection in W
00006 ; Returns 8-bit voltage in W
00007 ;-----------------------------------------------------------
00008
00000020 00009 Count EQU 20 ; Delay count
00000021 00010 ADcon EQU 21 ; ADC control word
00000022 00011 Vin EQU 22 ; Input voltage
00012
00013 ; Setup ADC .................................................
00014
00F7 01A1 00015 adin CLRF ADcon ; Zero control bits
00F8 00A1 00016 MOVWF ADcon ; load channel number
00F9 1003 00017 BCF STATUS,C ; Clear carry flag
Message[305]: Using default destination of 1 (file).
00FA 0DA1 00018 RLF ADcon ; to position..
Message[305]: Using default destination of 1 (file).
00FB 0DA1 00019 RLF ADcon ; ...channel select bits
00FC 3041 00020 MOVLW B'01000001' ; Analogue input setup code
Message[305]: Using default destination of 1 (file).
00FD 06A1 00021 XORWF ADcon ; Form control code
00FE 009F 00022 MOVWF ADCON0 ; f/8, RA0, done, enable
00023
00FF 1683 1303 00024 BANKSEL ADCON1 ; Bank 1
0101 3003 00025 MOVLW B'00000011' ; Analogue input setup code
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0102 009F 00026 MOVWF ADCON1 ; Left justify, analogue
0103 1283 1303 00027 BANKSEL ADCON0 ; Bank 0
00028
00029 ; Sample & hold settling delay 20us .........................
00030
MPASM 03.70.01 Released BASE1.ASM 3-28-2006 19:32:15 PAGE 11
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0105 3007 00031 getADC MOVLW 007 ;
0106 00A0 00032 MOVWF Count ;
Message[305]: Using default destination of 1 (file).
0107 0BA0 00033 down DECFSZ Count ;
0108 2907 00034 GOTO down ;
00035
00036 ; Read input ................................................
00037
0109 151F 00038 BSF ADCON0,GO ; start ADC..
010A 191F 00039 wait BTFSC ADCON0,GO ; and wait..
010B 290A 00040 GOTO wait ; for finish
010C 081E 00041 MOVF ADRESH,W ; store result
00042
00043 ; Set level indicator .......................................
00044
010D 00A2 00045 MOVWF Vin ; Get input volts
010E 3080 00046 MOVLW 080 ; Half scale
010F 1403 00047 BSF STATUS,C ; Compare
Message[305]: Using default destination of 1 (file).
0110 02A2 00048 SUBWF Vin ;
0111 1803 00049 BTFSC STATUS,C ;
0112 2916 00050 GOTO ledon ; input high
00051
0113 1086 00052 BCF PORTB,1 ; below 1.25V
0114 081E 00053 MOVF ADRESH,W ; reload result
0115 0008 00054 RETURN ; done
0116 1486 00055 ledon BSF PORTB,1 ; above 1.25V
0117 081E 00056 MOVF ADRESH,W ; reload result
0118 0008 00057 RETURN ; done
00058
00059 ; ...........................................................
00060
00313 ;
00314 ;----------------------------------------------------------
00315 ; SERIAL MEMORY DRIVER
00316 ; Write high address into 'HiReg' 00-3F
00317 ; Write low address into 'LoReg' 00-FF
00318 ; Load data send into 'SenReg'
00319 ; Read data received from 'RecReg'
00320 ;
00321 ; To initialise call 'inimem'
00322 ; To write call 'writmem'
00323 ; To read call 'readmem'
00324 ;
00325 INCLUDE "SERMEM.INC"
00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00002 ;
00003 ; SERMEM.INC MPB 14-1-06
00004 ;
00005 ; 24XX128 Serial Memory Driver
00006 ; Include file for demo system
00007 ;
00008 ; Version: under development
MPASM 03.70.01 Released BASE1.ASM 3-28-2006 19:32:15 PAGE 12
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00009 ;
00010 ; TO WRITE A BYTE
00011 ; Load data into SenReg
00012 ; Load address into Hireg,Loreg
00013 ; Call writmem
00014 ;
00015 ; TO READ A BYTE
00016 ; Load address into Hireg,Loreg
00017 ; Call readmem
00018 ; Read data from RecReg
00019 ;
00020 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00021
00022
00023 ; Data, address & control registers ;;;;;;;;;;;;;;;;;;;;;
00024
00000060 00025 SenReg EQU 0x60 ; writem data store
00000061 00026 HiReg EQU 0x61 ; High address store
00000062 00027 LoReg EQU 0x62 ; Low address store
00000063 00028 RecReg EQU 0x63 ; Receive data store
00000064 00029 ConReg EQU 0x64 ; Control byte store
00030
00031
00032 ; Initialisation sequence ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
00033
0119 0000 00034 inimem NOP ;
011A 1683 1303 00035 BANKSEL SSPCON2 ;
011C 3060 00036 MOVLW b'01100000' ; Set ACKSTAT,ACKDT bits
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
011D 0091 00037 MOVWF SSPCON2 ; Reset SEN,ACK bits
011E 3080 00038 MOVLW b'10000000' ;
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
011F 0094 00039 MOVWF SSPSTAT ; Speed & signal levels
0120 3013 00040 MOVLW 0x13 ; Clock = 50kHz
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0121 0093 00041 MOVWF SSPADD ; Load baud rate count-1
0122 1283 1303 00042 BANKSEL SSPCON ;
0124 3008 00043 MOVLW b'00001000' ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -