⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kx1.asm

📁 Alera 的8051 IP core的示例文件5个
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;SEARCH ADDRESS                                          -
;目的是为了转换地址单元为DDRAM地址单元,以方便           -
;定义显示位置                                            -
;汉字显示DDRAM位置为:第一行:80H----87H                 -
;                     第二行:90H----97H                 -
;		      第三行:88H----8FH                 -
;		      第四行:98H----9FH                 -
;---------------------------------------------------------
LCDPOS: PUSH	DPH			;地址转换子程序
	PUSH   	DPL
	PUSH	A
	MOV	DPTR,#LINE_ADD		;LINE-ADD为地址表指针
	MOV	A,FIRST_LIN
	MOVC	A,@A+DPTR
	ADD	A,FIRST_ADD
	MOV	START_ADD,A
	POP	A
	POP	DPL
	POP	DPH
	RET
LINE_ADD:
	DB  	00H,80H,90H,88H,98H,00H
;READ:   MOV     P3, #0FBH       	;读数据子程序
					;P3--CONTRAL	I/O
        NOP				;P3=11111011B   RS=1	R/W=1   READ DATA
        SETB E				;E=E(I/O)
        LCALL  DDD
        MOV A, P1			;P1=DATA(I/O)
        NOP
        CLR E
        RET



CHK_BUSY:
         LCALL  DDT9
         RET

PUSH    ACC
         CLR     RS			;读忙状态子程序
         SETB    RW
         SETB    E
CHK_B:   NOP
         JB   P0.7,CHK_B
         CLR  E
         POP  ACC
         RET


LCDWD:   ;写数据子程序
        LCALL	CHK_BUSY		;P3--CONTRAL	I/O
        NOP				;RS=1	RW=0  WRITE DATA
        SETB	RS
        CLR	RW
        SETB    E                       ;E=1
        MOV     P1, A			;P1=DATA(I/O)
        NOP
        CLR     E
        NOP
        MOV     P1,#0FFH
        LCALL   DDD
        RET



LCDWC:    ;写指令子程序
        LCALL	CHK_BUSY		;以确保上一指令/数据模块已经接收处理完
        NOP				;RS=0	WRITE	INSTRUTION
        CLR 	RS                      ;RW=0
        CLR	RW
        SETB E				;E=1
        MOV P1, A			;P1=DATA(I/O)
        NOP
        CLR E
        NOP
        MOV     P1,#0FFH
        LCALL   DDD
        RET

DELAY01: MOV  R6, #50
DE_A:   MOV  R7, #0
DE_B:   DJNZ R7, DE_B
        DJNZ R6, DE_A
        RET

DELAY02: MOV  R6, #6
DE_A1:   MOV  R7, #18h
DE_B1:   DJNZ R7, DE_B1
         DJNZ R6, DE_A1
         RET
DELAY03: MOV  R5,#02H
DE_6:	 MOV  R6,#0BFH
DE_4:    MOV  R7,#0BFH
DE_5:    DJNZ R7,DE_5
         DJNZ R6,DE_4
         NOP
         NOP
         DJNZ R5,DE_6
         RET

TAB:    DB  "杭州康芯电子公司"
        DB  "  热情为您服务  "
        DB  "www.kx-soc.com  "
        DB  "TEL0571-88914587"
TAB_2:  DB  "曾经沧海难为水  "
        DB  "  除却巫山不是云"
TAB_3:  DB  "GW-48EDA实验系统"
        DB  "  SOPC实验系统  "
        DB  "Nios实验开发系统"
        DB  "现代DSP 实验系统"

TAB_4:  DB  "现代计算机组成与"
        DB  "体系结构实验系统"
        DB  "嵌入式实验系统  "
        DB  "电子设计竞赛板  "

TAB_5:  DB  "高精度合成信号源"
        DB  "采用FPGA-DDS技术"
        DB  "具有ASK FSK PSK "
        DB  "AM/FM/PM调制输出"
;---------------------------------------------------------------------------------------------------------------------------------------------


datS	equ	28h		;control port
datc	equ	29h		;data port
chk_f	equ	2ah		;GPS Flag: ok =7
camma	equ	2bh		;--,--
RCAP2H  EQU     0CBH		;timer2h
RCAP2L  EQU     0CAH		;timer2l
T2CON   EQU     0C8H		;T2 control word

GPRM    EQU     30H		;$GPRMC
gps_buf	equ	37h		;GPS  data
hour	equ	2Eh		;time
min     equ     39h
sec     equ     3bh
NS      EQU     44H		;North or Sourth
EW      equ     51h		;East  or West
date    equ     63h		;Date
month   equ     65h
year    equ     67h


LED1    EQU     P3.5
LED2    EQU     P3.6



GPS:
	MOV	TMOD,#21H	;OSC=40MHz
	MOV	TH1,#245	;9600bps
	MOV	TL1,#245
	SETB	TR1
	MOV	SCON,#50H
        mov     r2,#5
lcd_rst:call    l_5h            ;delay for LCD
        djnz    r2,lcd_rst	;reset
        MOV     R0,#10H
        CLR     A
 RAM0:  		;RAM <== 0
        MOV     @R0,A
        INC     R0
        CJNE    R0,#080H,RAM0
        MOV	SP,#70H

	mov	dats,#01h	;01 clear LCD
	call	enable1
	mov	dats,#38h	;38 8bit 2 Rol 5*8
	call	enable1
	mov	dats,#0Fh	;0d OPEN LCD
	call	enable1
	mov	dats,#06h	;LEFT TO RIGHT
	call	enable1
	call	dsp0
        MOV	DPTR,#helo	;send PC "hello, you are welcome!"
	MOV	R2,#25
senddata:
	CLR	A
        MOVC	A,@A+DPTR
	MOV	SBUF,A
	JNB	TI,$
	CLR	TI
	INC	DPTR
	DJNZ	R2,senddata
;----------------------------
msg_1:
        mov     dptr,#gps_f	;Set GPRM fleg
        mov     r2,#7
        MOV     R1,#GPRM	;to RAM
msg_2:  clr     A
        movc    A,@A+DPTR
        MOV     @R1,A
        INC     DPTR
        INC     R1
        DJNZ    R2,MSG_2
;-------------------------------
        call    dsp_gps

wtdata0:
	call	get_0		;check GPRM flag
	mov	A,chk_f
;	CJNE	A,#7,wait4
	call	lcd_gps
wait4:
        jmp     wtdata0
;=========================================================

lcd_gps:MOV    2EH,37H		;Display GPS mesage
        MOV    2FH,38H

	mov	R0,#hour	;hour
        MOV	A,@R0
	SWAP	A
	INC	R0
	XCHD	A,@R0
        ADD     A,#9AH
	DA	A
H0_15:  ADD     A,#8
        DA      A
        CJNE    A,#24H,H_24     ;time adjust
H_24:   JC      H_0
        CJNE    A,#30H,H_25
H_25:   JC      H_26
        SUBB    A,#6
H_26:   CLR    C
        SUBB    A,#24H

H_0:	MOV	R1,A
	ANL	A,#0FH
	ORL	A,#30H
	MOV	@R0,A
	DEC	R0
	MOV	A,R1
        swap    A
 	ANL	A,#0FH
	ORL	A,#30H
	MOV	@R0,A

	mov	dats,#0c5h
	call	enable1          ;hour
        mov     r1,#hour
        mov     r2,#2
        call    dsp_r1

	mov	dats,#0c8h
	call	enable1
	mov	R1,#min		;min
	mov	R2,#2
	CALL	dsp_r1

	mov	dats,#0cbh
	call	enable1
	mov     r1,#sec		;sec
	mov	R2,#2
	CALL	dsp_r1

	MOV	R0,#gps_buf
	mov	R2,#8
	call	seg_2
        mov	dats,#08dh      ;date
	call	enable1
 	MOV	R1,0           ;r0=>r1
	mov	R2,#2
	CALL	dsp_r1

	mov	dats,#08ah       ;month
	call	enable1
	mov	R2,#2
	CALL	dsp_r1

	mov	dats,#087h       ;year
	call	enable1
	mov	R2,#2
	CALL	dsp_r1

        MOV	R0,#gps_buf
	call	seg_1
	mov	A,@R0
	CJNE	A,#41H,data_1	;"A"
	call	seg_1		;N/S
        mov	dats,#099h
	call	enable1
	MOV	R1,0             ;r0=>r1
	mov	R2,#2
	CALL	dsp_r1
        mov     datc,#2dh       ;dsplay "-"
        call    dspz
	mov	R2,#9
	CALL	dsp_r1


        MOV	R0,#gps_buf
        MOV     R2,#4
	call	seg_2           ;E_W
        mov	dats,#0D9h
	call	enable1
	MOV	R1,0
	mov	R2,#3
	CALL	dsp_r1
        mov     datc,#2dh       ;dsplay "-"
        call    dspz
	mov	R2,#9
	CALL	dsp_r1
data_1:  ret

seg_1:	mov	R2,#1
seg_2:	mov	A,@R0		;serch ","
	inc	R0
	CJNE	A,#2CH,seg_2
	inc	camma
	djnz	R2,seg_2
	ret

chk_0:  CLR     00H     	;check $GPRMC flag
	MOV	R0,#GPRM
	mov	chk_f,#0
	mov	R2,#7
chk_01:	MOV	R3,#200
	MOV	R4,#100
chk_1:	JBC	RI,chk_2
	DJNZ	R3,chk_1
	DJNZ	R4,chk_1
	sjmp	chk_4
chk_2:				; read one byte
        mov     A, SBUF		; from SBUF

chk_3:  XRL     A,@R0
        JNZ     chk_0
	inc	R0
	inc	chk_f
	DJNZ	R2,chk_01
        SETB    00H
chk_4:	ret

get_0:  call	chk_0		;check $GPRMC flag
        JNB     00H, GET_4
	mov	R1,#gps_buf
	mov	R2,#56
get_01:	mov	R3,#200
	MOV	R4,#100
get_1:	JBC	RI,get_2
	djnz	R3,get_1
	djnz	R4,get_1
	jmp	get_4
get_2:				; read one byte
        mov	A,SBUF
	mov	@R1,A
	inc	R1
	DJNZ	R2,get_01
get_4:	ret

dsp0:				;display string
	mov	dats,#080h
	call	enable1
	MOV	DPTR,#kxin	;KONXIN
	call	dsp_str
	mov	dats,#0c1h
	call	enable1
	MOV	DPTR,#kxin1
	call	dsp_str
	ret
DSP_GPS:			;display GPS
	mov	dats,#080h	;data structure
	call	enable1
	MOV	DPTR,#gps_date	;date
	call	dsp_str
	mov	dats,#0c0h
	call	enable1
	MOV	DPTR,#gps_time	;time
	call	dsp_str
	mov	dats,#094h
	call	enable1
	MOV	DPTR,#N_S	;N/S
	call	dsp_str
	mov	dats,#0D4h
	call	enable1
	MOV	DPTR,#E_W	;E/W
	call	dsp_str
	ret

dsp_str:
	CLR	A
	MOVC	A,@A+DPTR
	MOV	R2,A
	INC	DPTR
dsp_n:	CLR	A
	movc	A,@A+DPTR
	mov	datc,A
	call	dspz
	inc	DPTR
	DJNZ	R2,dsp_n
	ret

dsp_r1: mov     a,@r1
        mov     datc,a
        call    dspz
        inc     r1
        djnz    r2,dsp_r1
        ret

DSPz:	ACALL	l_4h		;display a char
	MOV	P1,DATc
        call    l_1h
	SETB	RS
        call    l_1h
	CLR	RW
        call    l_1h
	CLR	E
        call    l_1h
	SETB	E
	RET

ENABLE1: ACALL	l_4h		;LCD enable
	MOV	P1,#0FFH
        call    l_1h
	CLR	RS
        call    l_1h
	CLR	RW
        call    l_1h
	MOV	P1,DATs
        call    l_1h
	CLR	E
        call    l_1h
	SETB	E
	RET
L_1H:				;delay
        MOV    R6, #0aH
L_3H:
        DJNZ   R6, $
        RET
L_4H:   MOV    R7,#6H
        SJMP   L1_6H
L_5H:
        MOV    R7, #0F0H
l1_6h:  MOV    R6,#0
        DJNZ   R6,$
        djnz   R7,l1_6h
        RET

T0int:  reti
SIOint: reti

kxin:	db      17
        db      " KONXIN 89S51-GPS"

kxin1:	db	13,"communication "
	        ;0123456789012345678901234
helo:	db	"Hello, you are welcome!",0dh,0ah
hel_len	equ	24

GPS_f: 	db	"$GPRMC,"
gps_g:  db      "091812.000,A,2517.1884,N,11019.8345,E,0.00,,101008,,,A*7D "
len_g   equ     $-gps_g  ;  01234567890123456789

;--------------GPS mesage -------------------------
gps_date:	db	20,"date 20  /  /       "
gps_time:	db	20,"time   :  :         "
N_S:		db	20," N/S                "
E_W:		db	20," E/W                "
	ORG	0FFFH
	DB	0

        end

          END

          END
;----------------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -