📄 datalog.lst
字号:
0000FE C00A FFD8 00215 movff STATUS_TEMP_L, STATUS
000102 0010 00216 retfie
00217
00218 ;====================================================================
00219 ; Read a byte from the serial port
00220 ;--------------------------------------------------------------------
00221 ; W contains the byte that was received
00222 ;--------------------------------------------------------------------
000104 00223 UART_Getch
000104 0004 00224 clrwdt
000106 AA9E 00225 btfss PIR1, RCIF ; Wait for RX buffer full
000108 D7FD 00226 bra UART_Getch
00010A 50AE 00227 movf RCREG, W
00010C 0012 00228 return
00229
00230 ;====================================================================
00231 ; Write a byte to the serial port
00232 ;--------------------------------------------------------------------
00233 ; W contains the byte to be sent
00234 ;--------------------------------------------------------------------
00010E 00235 UART_Putch
00010E A89E 00236 btfss PIR1, TXIF ; Wait for TX buffer empty
000110 D7FE 00237 bra UART_Putch
000112 6EAD 00238 movwf TXREG
000114 0012 00239 return
00240
00241 ;====================================================================
00242 ; Write null terminated string to serial port from
00243 ; program memory
00244 ;--------------------------------------------------------------------
00245 ; TBLPTR Points to the start of the string
00246 ;--------------------------------------------------------------------
000116 00247 UART_Puts_loop
000116 DFFB 00248 rcall UART_Putch
000118 00249 UART_Puts
000118 0009 00250 tblrd*+
00011A 50F5 00251 movf TABLAT, W
00011C E1FC 00252 bnz UART_Puts_loop
00011E 0012 00253 return
00254
00255 ;====================================================================
00256 ; Read a sector from the ATA drive
00257 ;--------------------------------------------------------------------
000120 00258 ATA_Block_Read
000120 D82A 00259 rcall ATA_BSY_Wait ; Drive ready for command
MPASM 03.00 Released DATALOG.ASM 3-29-2004 12:59:54 PAGE 6
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000122 D83A 00260 rcall ATA_Send_LBA
000124 0E20 00261 movlw 0x20 ; Read sectors command
000126 6E00 00262 movwf TMP1
000128 0E17 00263 movlw 0x17 ; ATA Command regsiter
00012A D857 00264 rcall ATA_Reg8_Write
00012C 6A06 00265 clrf ATA_CNT
Message[314]: LFSR instruction is not supported on some versions of the 18Cxx2 devices.
Message[315]: Please refer to Microchip document DS80058A for more details.
00012E EE04 F000 00266 lfsr FSR0, ATA_BUF
000132 00267 ATA_Block_Read_Lp1
000132 D81C 00268 rcall ATA_DRQ_Wait ; Drive data waiting
000134 0E10 00269 movlw 0x10
000136 D85E 00270 rcall ATA_Reg16_Read
000138 5000 00271 movf TMP1, W
00013A 6EEE 00272 movwf POSTINC0
00013C 5001 00273 movf TMP2, W
00013E 6EEE 00274 movwf POSTINC0
000140 3E06 00275 incfsz ATA_CNT
000142 D7F7 00276 bra ATA_Block_Read_Lp1
000144 0012 00277 return
00278
00279 ;====================================================================
00280 ; Write a sector too the ATA drive
00281 ;--------------------------------------------------------------------
000146 00282 ATA_Block_Write
000146 D817 00283 rcall ATA_BSY_Wait ; Drive ready for command
000148 D827 00284 rcall ATA_Send_LBA
00014A 0E30 00285 movlw 0x30 ; Write sectors command
00014C 6E00 00286 movwf TMP1
00014E 0E17 00287 movlw 0x17 ; ATA Command regsiter
000150 D844 00288 rcall ATA_Reg8_Write
000152 6A06 00289 clrf ATA_CNT
Message[314]: LFSR instruction is not supported on some versions of the 18Cxx2 devices.
Message[315]: Please refer to Microchip document DS80058A for more details.
000154 EE04 F000 00290 lfsr FSR0, ATA_BUF
00291
000158 00292 ATA_Block_Write_Lp1
000158 D809 00293 rcall ATA_DRQ_Wait ; Drive ready for data
00015A 50EE 00294 movf POSTINC0, W
00015C 6E00 00295 movwf TMP1
00015E 50EE 00296 movf POSTINC0, W
000160 6E01 00297 movwf TMP2
000162 0E10 00298 movlw 0x10
000164 D854 00299 rcall ATA_Reg16_Write
000166 3E06 00300 incfsz ATA_CNT
000168 D7F7 00301 bra ATA_Block_Write_Lp1
00302
00016A 0012 00303 return
00304
00305 ;====================================================================
00306 ; Wait for DRQ to indicate drive is ready for data
00307 ;--------------------------------------------------------------------
00016C 00308 ATA_DRQ_Wait
MPASM 03.00 Released DATALOG.ASM 3-29-2004 12:59:54 PAGE 7
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00016C 0E17 00309 movlw 0x17 ; Drive status register
00016E D82A 00310 rcall ATA_Reg8_Read
000170 A600 00311 btfss TMP1, 3 ; DRQ bit (data request)
000172 D7FC 00312 bra ATA_DRQ_Wait
000174 0012 00313 return
00314
00315 ;====================================================================
00316 ; Wait for BSY to indicate drive is ready for a command
00317 ;--------------------------------------------------------------------
000176 00318 ATA_BSY_Wait
000176 0E17 00319 movlw 0x17 ; Drive status register
000178 D825 00320 rcall ATA_Reg8_Read
00017A BE00 00321 btfsc TMP1, 7 ; BSY bit (busy)
00017C D7FC 00322 bra ATA_BSY_Wait
00017E 0012 00323 return
00324
00325 ;====================================================================
00326 ; Zero out LBA address
00327 ;--------------------------------------------------------------------
000180 00328 ATA_A_RESET
000180 6A02 00329 clrf ATA_A0 ; Point to first sector
000182 6A03 00330 clrf ATA_A1
000184 6A04 00331 clrf ATA_A2
000186 6A05 00332 clrf ATA_A3
000188 0012 00333 return
00334
00335 ;====================================================================
00336 ; Increment LBA address by one
00337 ;--------------------------------------------------------------------
00018A 00338 ATA_A_INC
00018A 3E02 00339 incfsz ATA_A0 ; Point to next sector
00018C D004 00340 bra ATA_A_INC_EXIT
00018E 3E03 00341 incfsz ATA_A1
000190 D002 00342 bra ATA_A_INC_EXIT
000192 4A04 00343 infsnz ATA_A2
000194 2A05 00344 incf ATA_A3
000196 00345 ATA_A_INC_EXIT
000196 0012 00346 return
00347
00348 ;====================================================================
00349 ; Transfer LBA address to drive
00350 ;--------------------------------------------------------------------
000198 00351 ATA_Send_LBA
000198 0E01 00352 movlw 0x01 ; Sector count
00019A 6E00 00353 movwf TMP1
00019C 0E12 00354 movlw 0x12 ; ATA Sector count
00019E D81D 00355 rcall ATA_Reg8_Write
0001A0 C002 F000 00356 movff ATA_A0, TMP1
0001A4 0E13 00357 movlw 0x13 ; ATA LBA 0-7 register
0001A6 D819 00358 rcall ATA_Reg8_Write
0001A8 C003 F000 00359 movff ATA_A1, TMP1
0001AC 0E14 00360 movlw 0x14 ; ATA LBA 8-15 register
0001AE D815 00361 rcall ATA_Reg8_Write
MPASM 03.00 Released DATALOG.ASM 3-29-2004 12:59:54 PAGE 8
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0001B0 C004 F000 00362 movff ATA_A2, TMP1
0001B4 0E15 00363 movlw 0x15 ; ATA LBA 16-23 register
0001B6 D811 00364 rcall ATA_Reg8_Write
0001B8 5005 00365 movf ATA_A3, W
0001BA 0940 00366 iorlw B'01000000' ; Indicate address is LBA not CHS
0001BC 6E00 00367 movwf TMP1
0001BE 0E16 00368 movlw 0x16 ; ATA LBA 24-27 register
0001C0 D80C 00369 rcall ATA_Reg8_Write
0001C2 0012 00370 return
00371 ;====================================================================
00372 ; Read a register from the ATA drive (8 bit)
00373 ;--------------------------------------------------------------------
00374 ; W contains address
00375 ; TMP1 contains data
00376 ;--------------------------------------------------------------------
0001C4 00377 ATA_Reg8_Read
0001C4 AA82 00378 btfss PORTC, 5 ; Wait until ready
0001C6 D7FE 00379 bra ATA_Reg8_Read
0001C8 0B1F 00380 andlw B'00011111' ; Set address
0001CA 6E82 00381 movwf PORTC
0001CC 908D 00382 bcf LATE, 0 ; DIOR low
0001CE 0000 00383 nop ; Wait
0001D0 0000 00384 nop
0001D2 5081 00385 movf PORTB, W ; Get data
0001D4 6E00 00386 movwf TMP1
0001D6 808D 00387 bsf LATE, 0 ; DIOR high
0001D8 0012 00388 return
00389
00390 ; +-----------------------------------+
00391 ; | PORTC 4-0 to ATA register - Read |
00392 ; +------+----------------------------+
00393 ; | Addr | Register |
00394 ; +------+----------------------------+
00395 ; | 0x0E | Alternate status |
00396 ; | 0x0F | Drive address |
00397 ; | 0x10 | Data (16 bit reg) |
00398 ; | 0x11 | Features |
00399 ; | 0x12 | Sector count |
00400 ; | 0x13 | LBA 0-7 |
00401 ; | 0x14 | LBA 8-15 |
00402 ; | 0x15 | LBA 16-23 |
00403 ; | 0x16 | LBA 24-27 |
00404 ; | 0x17 | Status |
00405 ; +------+----------------------------+
00406
00407 ;====================================================================
00408 ; Write a register to the ATA drive (8 bit)
00409 ;--------------------------------------------------------------------
00410 ; W contains address
00411 ; TMP1 contains data
00412 ;--------------------------------------------------------------------
0001DA 00413 ATA_Reg8_Write
0001DA AA82 00414 btfss PORTC, 5 ; Wait until ready
MPASM 03.00 Released DATALOG.ASM 3-29-2004 12:59:54 PAGE 9
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0001DC D7FE 00415 bra ATA_Reg8_Write
0001DE 0B1F 00416 andlw B'00011111' ; Set address
0001E0 6E82 00417 movwf PORTC
0001E2 5000 00418 movf TMP1, W ; Set data
0001E4 6E81 00419 movwf PORTB
0001E6 6A93 00420 clrf TRISB ; Port for output
0001E8 928D 00421 bcf LATE, 1 ; DIOW low
0001EA 0000 00422 nop ; Wait
0001EC 0000 00423 nop
0001EE 828D 00424 bsf LATE, 1 ; DIOW high
0001F0 6893 00425 setf TRISB ; Port for input
0001F2 0012 00426 return
00427
00428 ; +-----------------------------------+
00429 ; | PORTC 4-0 to ATA register - Write |
00430 ; +------+----------------------------+
00431 ; | Addr | Register |
00432 ; +------+----------------------------+
00433 ; | 0x0E | Device control |
00434 ; | 0x10 | Data (16 bit reg) |
00435 ; | 0x11 | Features |
00436 ; | 0x12 | Sector count |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -