📄 rx900-ok.lst
字号:
MPASM 02.70 Released RX900-OK.ASM 3-10-2003 14:59:15 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;***********************************************************************************
00002 ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00003 ; project: RF 900 MHz radio communication module
00004 ; filename: Rx900-OK.asm
00005 ; mcu: pic12c509a
00006 ; pin define:
00007 ; ________
00008 ; VCC--| o |--VSS
00009 ; ENABLE--| |--SOLENOID
00010 ; NC--| |--BUZZER
00011 ; DATA--| |--NC
00012 ; --------
00013 ;***********************************************************************************
00014 ;***********************************************************************************
00015 ; The STATUS register
00016
00017 ;bit 7: GPWUF: GPIO reset bit
00018 ; 1 = Reset due to wake-up from SLEEP on pin change
00019 ; 0 = After power up or other reset
00020 ;bit 6: Unimplemented
00021 ;bit 5: PA0: Program page preselect bits
00022 ; 1 = Page 1 (200h - 3FFh) - PIC12C509, PIC12C509A, PIC12CR509A and PIC12CE519
00023 ; 0 = Page 0 (000h - 1FFh) - PIC12C5XX
00024 ; Each page is 512 bytes.
00025 ; Using the PA0 bit as a general purpose read/write bit in devices which do not
00026 ; use it for program
00027 ; page preselect is not recommended since this may affect upward compatibility
00028 ; with future products.
00029 ;bit 4: TO: Time-out bit
00030 ; 1 = After power-up, CLRWDT instruction, or SLEEP instruction
00031 ; 0 = A WDT time-out occurred
00032 ;bit 3: PD: Power-down bit
00033 ; 1 = After power-up or by the CLRWDT instruction
00034 ; 0 = By execution of the SLEEP instruction
00035 ;bit 2: Z: Zero bit
00036 ; 1 = The result of an arithmetic or logic operation is zero
00037 ; 0 = The result of an arithmetic or logic operation is not zero
00038 ;bit 1: DC: Digit carry/borrow bit (for ADDWF and SUBWF instructions)
00039 ; ADDWF
00040 ; 1 = A carry from the 4th low order bit of the result occurred
00041 ; 0 = A carry from the 4th low order bit of the result did not occur
00042 ; SUBWF
00043 ; 1 = A borrow from the 4th low order bit of the result did not occur
00044 ; 0 = A borrow from the 4th low order bit of the result occurred
00045 ;bit 0: C: Carry/borrow bit (for ADDWF, SUBWF and RRF, RLF instructions)
00046 ;***********************************************************************************
00047 ;The code init. OPTION set.
00048
00049 ;bit 7: GPWU: Enable wake-up on pin change (GP0, GP1, GP3)
00050 ; 1 = Disabled
00051 ; 0 = Enabled
00052 ;bit 6: GPPU: Enable weak pull-ups (GP0, GP1, GP3)
00053 ; 1 = Disabled
MPASM 02.70 Released RX900-OK.ASM 3-10-2003 14:59:15 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00054 ; 0 = Enabled
00055 ;bit 5: T0CS: Timer0 clock source select bit
00056 ; 1 = Transition on T0CKI pin
00057 ; 0 = Transition on internal instruction cycle clock, Fosc/4
00058 ;bit 4: T0SE: Timer0 source edge select bit
00059 ; 1 = Increment on high to low transition on the T0CKI pin
00060 ; 0 = Increment on low to high transition on the T0CKI pin
00061 ;bit 3: PSA: Prescaler assignment bit
00062 ; 1 = Prescaler assigned to the WDT
00063 ; 0 = Prescaler assigned to Timer0
00064 ;bit 2-0: PS2:PS0: Prescaler rate select bits
00065 ; Bit Value Timer0 Rate WDT Rate
00066 ; 000 1 : 2 1 : 1
00067 ; 001 1 : 4 1 : 2
00068 ; 010 1 : 8 1 : 4
00069 ; 011 1 : 16 1 : 8
00070 ; 100 1 : 32 1 : 16
00071 ; 101 1 : 64 1 : 32
00072 ; 110 1 : 128 1 : 64
00073 ; 111 1 : 256 1 : 128
00074 ;***********************************************************************************
00075 ;------------------------
00076 ;special register define
00077 ;------------------------
00000000 00078 INDF EQU 0H
00000001 00079 TMR0 EQU 1H
00000002 00080 PCL EQU 2H
00000003 00081 STATUS EQU 3H
00000004 00082 FSR EQU 4H
00000005 00083 OSCCAL EQU 5H
00000006 00084 GPIO EQU 6H
00085 ;-------------------
00086 ;special bit define
00087 ;-------------------
00000000 00088 C EQU 0
00000001 00089 DC EQU 1
00000002 00090 Z EQU 2
00000003 00091 PD EQU 3
00000004 00092 TO EQU 4
00000005 00093 PA0 EQU 5
00094 ;
00000007 00095 GPWUF EQU 7
00096
00097 ;------------------------
00098 ;General register define
00099 ;------------------------
00000008 00100 COMPARE_BUF EQU 08H
00000009 00101 COUNTER_BUF EQU 09H
0000000A 00102 TEMP_BUF EQU 0AH
00000010 00103 PUL_BREADTH EQU 10H
00000011 00104 BIT_CONT EQU 11H
00000012 00105 DATA_BUF EQU 12H
00000013 00106 DATA_TMP EQU 13H
MPASM 02.70 Released RX900-OK.ASM 3-10-2003 14:59:15 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000014 00107 FLG_QC EQU 14H
00000015 00108 R0 EQU 15H
00000016 00109 R1 EQU 16H
00000017 00110 R2 EQU 17H
00000018 00111 AGO_BIT EQU 18H
00000019 00112 NOW_BIT EQU 19H
0000001A 00113 LOOK_CONT EQU 1AH
0000001B 00114 ID_CONT EQU 1BH
0000001C 00115 ID_CODE EQU 1CH
0000001D 00116 COUNT1 EQU 1DH
0000001E 00117 BIT_BUF EQU 1EH
00118 ;---------------------
00119 ;port define
00120 ;---------------------
00000002 00121 DAT EQU 2
00000000 00122 ENABLE EQU 0
00000005 00123 SPRAY EQU 5
00000004 00124 BUZZER EQU 4
00125 ;---------------------
00126 ;Value define
00127 ;---------------------
00128 ; pulse breadth value
00129 ;
00000041 00130 ONE_BREADTHUP SET D'65' ; +1
0000003C 00131 ONE_BREADTH SET D'60' ; BIT "1" 0.5mS
00000037 00132 ONE_BREADTHDN SET D'55' ; -1
00133
0000002D 00134 ZER_BREADTHUP SET D'45' ; +1
00000028 00135 ZER_BREADTH SET D'40' ; BIT "0" 1mS
00000023 00136 ZER_BREADTHDN SET D'35' ; -1
00137
00000019 00138 STA_BREADTHUP SET D'25' ; +1
00000014 00139 STA_BREADTH SET D'20' ; BIT "STA" 2mS
0000000F 00140 STA_BREADTHDN SET D'15' ; -1
00141
00142
00143 #DEFINE BLOCK1 BCF STATUS,5
00144 #DEFINE BLOCK2 BSF STATUS,5
00145 ;-------------------------------
00146 ;**** SPRAY long command: 0FH
00147 ;**** SPRAY brief command: 55H
00148 ;**** BUZZER command: AAH
00149 ;*********************************************************************
00150 ;*********************************************************************
0000 00151 ORG 000H
0000 0025 00152 MOVWF OSCCAL
0001 0A10 00153 GOTO MAIN
00154 ;*********************************************************************
00155 ;**** the NOP is uniform to address 010H of ROM
0002 0000 00156 NOP
0003 0000 00157 NOP
0004 0000 00158 NOP
0005 0000 00159 NOP
MPASM 02.70 Released RX900-OK.ASM 3-10-2003 14:59:15 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0006 00160 GET_ID
0006 021B 00161 MOVFW ID_CONT ; ID number to W
0007 01E2 00162 ADDWF PCL ; Add W to PC
0008 0812 00163 RETLW 012H ; the ID number can alter at program MCU
0009 08AA 00164 RETLW 0AAH
000A 08AA 00165 RETLW 0AAH
00166 ;*********************************************************************
0010 00167 ORG 010H
0010 00168 MAIN
0010 05A3 00169 BLOCK2
0011 0A10 00170 GOTO _MAIN
00171
00172 ;*********************************************************************
00173 ; the code receive singleton bit
00174 ; pulse raise high start count of TMR0
00175 ; pulse fall low stop count
00176 ; output parameter:
00177 ; COUNTER_BUF--pulse number count
00178 ;*********************************************************************
0012 00179 RECEIVE_BIT
0012 0CCC 00180 MOVLW B'11001100' ; WDT rate 1 : 16
0013 0002 00181 OPTION
0014 0004 00182 CLRWDT
00183 ;**** the R1 restrict search time in 2.2~40ms
0015 0C28 00184 MOVLW D'40' ;
0016 0036 00185 MOVWF R1 ;
0017 00186 RECE_LOOP
0017 02F6 00187 DECFSZ R1,F
0018 0A1B 00188 GOTO COUNT_LOOP
0019 05A3 00189 BLOCK2
001A 0A1B 00190 GOTO M_LOOP
00191 ;=========================================
001B 00192 COUNT_LOOP
001B 0C14 00193 MOVLW D'20' ; 20 * 5 = 100US
001C 0035 00194 MOVWF R0 ; 20 * 5 * 40 = 4ms
001D 00195 WAIT_HIGH
001D 0646 00196 BTFSC GPIO,DAT ;
001E 0A22 00197 GOTO START_COUNT ;
001F 02F5 00198 DECFSZ R0,F
0020 0A1D 00199 GOTO WAIT_HIGH
0021 0A17 00200 GOTO RECE_LOOP
00201 ;=========================================
00202 ;**** start count
0022 00203 START_COUNT
0022 0061 00204 CLRF TMR0 ; Load value into TMR0
0023 00205 WAIT_LOW
0023 0746 00206 BTFSS GPIO,DAT ;
0024 0A2A 00207 GOTO CHECK_TMR0 ;
0025 0C3C 00208 MOVLW D'60' ; 55 * 40 = 2.2ms
0026 0081 00209 SUBWF TMR0,W ; compare counter value
0027 0603 00210 SKPNC ; TMR0 arrive D'55' return
0028 0A17 00211 GOTO RECE_LOOP
0029 0A23 00212 GOTO WAIT_LOW
MPASM 02.70 Released RX900-OK.ASM 3-10-2003 14:59:15 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00213 ;=========================================
002A 00214 CHECK_TMR0
002A 0C28 00215 MOVLW D'40' ; 40 * 40 = 1.6MS
002B 0081 00216 SUBWF TMR0,W
002C 0703 00217 SKPC ; TMR0 > 40US, skip
002D 0A17 00218 GOTO RECE_LOOP
00219 ;=========================================
002E 00220 REC00
00221 ;**** R0 1ms count, COUNTER_BUF count pulse number
002E 0078 00222 CLRF AGO_BIT
002F 0079 00223 CLRF NOW_BIT
0030 0069 00224 CLRF COUNTER_BUF
0031 0C5B 00225 MOVLW D'91' ; 91 * 11 = 1001us
0032 0035 00226 MOVWF R0
00227 ;=========================================
0033 00228 REC01
0033 0206 00229 MOVFW GPIO
0034 0E04 00230 ANDLW B'00000100'
0035 0039 00231 MOVWF NOW_BIT
0036 0198 00232 XORWF AGO_BIT,W
0037 0743 00233 SKPZ
0038 02A9 00234 INCF COUNTER_BUF
0039 0219 00235 MOVFW NOW_BIT
003A 0038 00236 MOVWF AGO_BIT
003B 02F5 00237 DECFSZ R0
003C 0A33 00238 GOTO REC01
003D 0800 00239 RETLW 0
00240 ;*********************************************************************
00241 ;initialize I/O port
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -