📄 up2dsptest1.asm
字号:
call RECEI_BYTE
CJNE A,#1BH, FILE_ERR1
call RECEI_BYTE ; 6FH = 'o'
call RECEI_BYTE ; 0d = carriage return
call RECEI_BYTE ; 0a = line feed
;;;;;;;;;;;;;;;;;;;;;;;;;;SEND RESERVED BYTE TO ADDRESS 0;;;;;;;;;;;;;;;
MOV P0, #04H
CLR UALE
MOV P0, #00H ;address 0x00;
CLR UWR
SETB UWR
SETB UALE
; retrieve low byte of address, byte0lower
MOV P0, #05H
CLR UALE
MOV P0, #0H ;address 0x00;
CLR UWR
SETB UWR
SETB UALE
; send RW request in addr 02
; do write (1) first and then read (0)
MOV P0, #02H
CLR UALE
MOV P0, #1 ; write
CLR UWR
SETB UWR
SETB UALE
MOV P0, #06H
CLR UALE
MOV P0, byte0high ;high byte of pm data address 0
CLR UWR
SETB UWR
SETB UALE
MOV A,byte0high
call seebuf
MOV P0, #06H
CLR UALE
MOV P0, byte0middle ;middle byte of pm data address 0
CLR UWR
SETB UWR
SETB UALE
MOV A,byte0middle
call seebuf
MOV P0, #06H
CLR UALE
MOV P0, byte0low ;low byte of pm data address 0
CLR UWR
SETB UWR
SETB UALE
MOV A,byte0low
call seebuf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;END;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOV A, #'F'
call TRANS_BYTE
MOV A, #'L'
call TRANS_BYTE
MOV A, #'O'
call TRANS_BYTE
MOV A, #'A'
call TRANS_BYTE
MOV A, #'D'
call TRANS_BYTE
JMP label ;await for command, DO IT ALL OVER AGAIN
;*****************************************************
; DOING FILE TRANSFER, LOADING INTO DSP CHIP
;*****************************************************
; R2 indicate PM/DM
; 0xa, b stores current address being transferred
; 0xc,d,e stores current data being transferred
; 0x10,11,12,13 stores checksum value
;
prompt3: db 'Download ',0
FILE_XFR:
; mov dptr,#prompt3
; lcall outstr
#if 0
Loop:call RECEI_BYTE
call TRANS_BYTE ;KK test to see all the data transfer from
CJNE A,#'o', Loop ;Hyper Terminal
#endif
call RECEI_BYTE
CJNE A,#1BH, FILE_ERR2
call RECEI_BYTE
CJNE A,#69H, FILE_ERR2 ; i = x69
#if 0
;send command to reset chip
MOV A, #1
#if NOT_USE_MOVX
MOV P0, #00H ; uP address 0
CLR UALE
MOV P0, A
CLR UWR
SETB UWR
SETB UALE
#else
; this section use Movx
MOV R0, #00H ; R0= external address
MOVX @R0, A
#endif
#endif
FILE_new_seg:
call RECEI_BYTE
CJNE A,#0DH, FILE_ERR2 ; carriage return = 0d0a but only see 0d
;KK can see it in scope so it has to take into account
call RECEI_BYTE
CJNE A,#0aH, FILE_ERR2 ; carriage return = 0d0a but only see 0d
call RECEI_BYTE
CJNE A,#40H, FILE_chk_end1 ; @
call RECEI_BYTE
CJNE A,#'P', FILE_DM
;FILE_PM:
#if testmode
call TRANS_BYTE
#endif
MOV R2, #0H ; flag to be used when sending to dsp
SJMP FILE_SEG1 ;continue in common code segment 1
FILE_DM:
CJNE A,#'D', FILE_ERR2
#if testmode
call TRANS_BYTE
#endif
MOV R2, #40H ; flag to be used when sending to dsp
SJMP FILE_SEG1
FILE_chk_end1:
JMP FILE_chk_end ;KK
;**************
FILE_ERR2:
JMP FILE_ERR
;***********************************
; detected the end of segment, now check checksum
FILE_end_seg:
MOV A, #'h'
call TRANS_BYTE
call RECEI_BYTE
CJNE A,#'1', FILE_ERR2
call RECEI_BYTE ;
CJNE A,#'2', FILE_ERR2
call RECEI_BYTE ;
CJNE A,#'3', FILE_ERR2
#if 0
MOV A, 12H
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 12H
SWAP A
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 11H
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 11H
SWAP A
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 10H
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 10H
SWAP A
CALL BCD_ASCII
CALL TRANS_BYTE
jmp FILE_ERR2
#endif
#if 1
CALL GET_BCD
CJNE A, 13H, FILE_ERR2
CALL GET_BCD
CJNE A, 12H, FILE_ERR2
CALL GET_BCD
CJNE A, 11H, FILE_ERR2
CALL GET_BCD
CJNE A, 10H, FILE_ERR2
#endif
MOV A, #'o'
call TRANS_BYTE
JMP FILE_new_seg
;***************
FILE_SEG1:
#if testmode_further
MOV A, #'V'
call TRANS_BYTE
#endif
call RECEI_BYTE
CJNE A,#'A', FILE_ERR2
#if testmode_further
MOV A, #'W'
call TRANS_BYTE
#endif
call RECEI_BYTE
CJNE A,#0DH, FILE_ERR2 ; carriage return = 0d0a
#if testmode_further
MOV A, #'X'
call TRANS_BYTE
#endif
;KK reenable. Can see it from scope
call RECEI_BYTE
CJNE A,#0AH, FILE_ERR2
;***************get DSP address
CALL GET_BCD
MOV 11H, A ; checksum
ORL A, R2 ; mem flag set in
; high byte ready
MOV DPH, A ; remember high byte of address
#if testmode_further
call trans_byte
#endif
; get low byte of address , send in addr 05
CALL GET_BCD ; getting a BCD valued byte in A
MOV DPL, A ; remember low byte of address
#if testmode_further
call trans_byte
#endif
MOV 10H, A ; checksum
MOV 12H, #0 ; checksum
MOV 13H, #0 ; checksum
call RECEI_BYTE
CJNE A,#0DH, FILE_ERR3 ; carriage return = 0d0a
;KK reaenable
call RECEI_BYTE
CJNE A,#0AH, FILE_ERR3
FILE_seg_data:
;MOV A, #'H'
;call TRANS_BYTE
;********this is the GET_BCD routine except that it now also check for #
;GET_BCD:
CALL RECEI_BYTE ;getting first nibble of BCD value
CJNE A,#'#', FILE_data
JMP FILE_end_seg
FILE_ERR3:
jmp FILE_ERR
FILE_data:
; CALL TRANS_BYTE
CALL ASCII_BCD ; input A return A
SWAP A ;high nibble now in place
MOV R3,A ;R3= holding output byte
CALL RECEI_BYTE ;getting second nibble of BCD value
; CALL TRANS_BYTE
CALL ASCII_BCD ; input A return A
ORL A, R3 ;put low nibble together with high nibble
;************end of modified GET_BCD
MOV 0CH, A ; remember high byte of data
#if testmode_further
MOV A, #'Y'
call TRANS_BYTE
#endif
MOV A, DPH ;check here !!!!!!!!!
CJNE A, #0, Kcont ;KK
MOV A, DPL
CJNE A, #0, Kcont ;KK
MOV byte0high, 0CH
#if testmode_further
MOV A, #'L'
call TRANS_BYTE
#endif
jmp skip8051_0;
#if 1
SEEBUF:
MOV 38H, A
SWAP A
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 38H
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A,38H
RET
#endif
Kcont:
; now set uP address
; retrieve high byte of address, 0AH
#if NOT_USE_MOVX
; this section not using movx
; MOV R0, #04H ; R0= external address
MOV P0, #04H
CLR UALE
MOV P0, DPH
CLR UWR
SETB UWR
SETB UALE
#if testmode
MOV A, DPH
call trans_byte
#endif
#else
; this section for use of movx
MOV R0, #04H ; R0= external address
MOV A, DPH ; MOVX not accept @R0, DPH
MOVX @R0, A
#endif
; retrieve low byte of address, 0BH
#if NOT_USE_MOVX
MOV P0, #05H
CLR UALE
MOV P0, DPL
CLR UWR
SETB UWR
SETB UALE
#if testmode
MOV A, DPL
call trans_byte
#endif
#else
; this section use Movx
MOV R0, #05H ; R0= external address
MOV A, DPH ; MOVX not accept @R0, DPL
MOVX @R0, A
#endif
; send RW request in addr 02
; do write (1) first and then read (0)
; MOV A, #1 ; write
#if NOT_USE_MOVX
MOV P0, #02H
CLR UALE
MOV P0, #1 ; write
CLR UWR
SETB UWR
SETB UALE
#else
; this section use movx
MOV R0, #02H ; R0= external address
MOV A, #1 ; MOVX not accept @R0, #1
MOVX @R0, A ; write
#endif
;********* begin getting one byte of data from file and send to DSP until one line is done
; get high byte of data
; MOV 0CH, A ;this line moved up already
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV A, 0CH
MOV P0, A
CLR UWR
SETB UWR
SETB UALE
MOV A, 0cH
#if testmode
call trans_byte
#endif
#else
; this section use movx
MOV R0, #06H ; R0= external address
MOV A, 0CH ; MOVX not accept @R0, 0ch
MOVX @R0, A
#endif
skip8051_0:
; get low byte of data
CALL GET_BCD ; getting a BCD valued byte in A
MOV 0DH, A ; remember data
MOV A, DPH
CJNE A, #0, Kcont1 ;KK
MOV A, DPL
CJNE A, #0, Kcont1 ;KK
MOV byte0middle, 0DH
#if testmode_further
MOV A, #'M'
call TRANS_BYTE
#endif
jmp skip8051_1;
Kcont1:
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV A, 0DH
MOV P0, A
CLR UWR
SETB UWR
SETB UALE
#if testmode
call trans_byte
#endif
#else
; this section use movx
MOV R0, #06H ; R0= external address
MOVX @R0, A
#endif
; get one more low byte if it is PM data
CJNE R2, #0H, FILE_SEG_DM
skip8051_1:
; get one more low byte of if it is PM data
CALL GET_BCD ; getting a BCD valued byte in A
MOV 0EH, A ; remember data
MOV A, DPH
CJNE A, #0, Kcont2 ;KK
MOV A, DPL
CJNE A, #0, Kcont2 ;KK
MOV byte0low, 0EH;
#if testmode_further
MOV A, #'N'
call TRANS_BYTE
#endif
call RECEI_BYTE
CJNE A,#0DH, FILE_ERR ; carriage return = 0d0a
;KK reenable
call RECEI_BYTE
CJNE A,#0AH, FILE_ERR
INC DPTR
jmp skip8051_2
Kcont2:
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV A, 0EH
MOV P0, A
CLR UWR
SETB UWR
SETB UALE
#if testmode
call trans_byte
#endif
#else
; this section use movx
MOV R0, #06H ; R0= external address
MOVX @R0, A
#endif
FILE_SEG_DM:
call RECEI_BYTE
CJNE A,#0DH, FILE_ERR ; carriage return = 0d0a
;KK reenable
call RECEI_BYTE
CJNE A,#0AH, FILE_ERR
;********* now read back from DSP to see if transfer was correct
; now set uP address
; retrieve high byte of address, 0AH
#if NOT_USE_MOVX
; this section not using movx
; MOV R0, #04H ; R0= external address
MOV P0, #04H
CLR UALE
MOV P0, DPH
CLR UWR
SETB UWR
SETB UALE
#else
; this section for use of movx
MOV R0, #04H ; R0= external address
MOV A, DPH ; MOVX not accept anything other than A
MOVX @R0, A
#endif
; retrieve low byte of address, 0BH
#if NOT_USE_MOVX
MOV P0, #05H
CLR UALE
MOV P0, DPL
CLR UWR
SETB UWR
SETB UALE
#else
; this section use Movx
MOV R0, #05H ; R0= external address
MOV A, DPL ; MOVX not accept anything other than A
MOVX @R0, A
#endif
; send RW request in addr 02
; do write (1) first and then read (0)
; MOV A, #0 ; read
#if NOT_USE_MOVX
MOV P0, #02H
CLR UALE
MOV P0, #0 ; read
CLR UWR
SETB UWR
SETB UALE
#else
; this section use movx
MOV R0, #02H ; R0= external address
MOV A, #0 ; MOVX not accept anything other than A
MOVX @R0, A ; read
#endif
; now increment address
INC DPTR
CJNE R2, #0H, FILE_SEG_RD_DM
JMP skip8051_2 ;skip DSP read and verify after program has been loaded
;SJMP FILE_read_chk
;***********************
FILE_ERR:
MOV A, #'e' ; e =0x65
call TRANS_BYTE
MOV A, #'r' ; r = 0x72
call TRANS_BYTE
MOV A, #' ' ; = 0x20
call TRANS_BYTE
JMP label
;***********************
;********** after setting address in DSP now read the data and check correctness
FILE_read_chk:
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV P0, #0FFH ;prepare read input
CLR URD
MOV A, P0 ;get one byte from DSP
SETB URD
SETB UALE
call trans_byte
#else
; this section use movx
MOV R0, #06H ;get one byte from DSP
MOVX A, @R0
#endif
CJNE A, 0CH, FILE_ERRK ; high byte
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV P0, #0FFH ;prepare read input
CLR URD
MOV A, P0 ;get one byte from DSP
SETB URD
SETB UALE
call trans_byte
#else
; this section use movx
MOV R0, #06H ;get one byte from DSP
MOVX A, @R0
#endif
CJNE A, 0DH, FILE_ERRK ; low byte
; check one more low byte if it is PM data
CJNE R2, #0H, FILE_SEG_RD_DM
#if NOT_USE_MOVX
MOV P0, #06H
CLR UALE
MOV P0, #0FFH ;prepare read input
CLR URD
MOV A, P0 ;get one byte from DSP
SETB URD
SETB UALE
call trans_byte
#else
; this section use movx
MOV R0, #06H ;get one byte from DSP
MOVX A, @R0
#endif
CJNE A, 0EH, FILE_ERRK ; low byte
skip8051_2:
; add checksum for PM data
MOV A, 10H ; low byte
ADD A, 0EH
MOV 10H, A
MOV A, 11H
ADDC A, 0DH
MOV 11H, A
MOV A, 12H
ADDC A, 0CH
MOV 12H, A
MOV A, 13H
ADDC A, #0
MOV 13H, A
#if 0
MOV A, #'p'
CALL TRANS_BYTE
MOV A, 10H
CALL BCD_ASCII
CALL TRANS_BYTE
MOV A, 10H
SWAP A
CALL BCD_ASCII
CALL TRANS_BYTE
#endif
JMP FILE_seg_data
FILE_ERRK:
MOV A, #'C'
call TRANS_BYTE
JMP label
FILE_SEG_RD_DM:
; add checksum for DM data
CLR C
MOV A, 10H ; low byte
ADD A, 0DH
MOV 10H, A
MOV A, 11H
ADDC A, 0CH
MOV 11H, A
MOV A, 12H
ADDC A, #0
MOV 12H, A
MOV A, 13H
ADDC A, #0
MOV 13H, A
JMP FILE_seg_data
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -