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

📄 main.asm

📁 SUNPLUS的关于LCD的驱动程序。包含了SUN的一些基本指令及算法。
💻 ASM
字号:
;==================================================================================
; The information contained herein is the exclusive property of
; Sunplus Technology Co. And shall not be distributed, reproduced,
; or disclosed in whole in part without prior written permission.
;       (C) COPYRIGHT 2004   SUNPLUS TECHNOLOGY CO.                                  
;                   ALL RIGHTS RESERVED
; The entire notice above must be reproduced on all authorized copies.
;==================================================================================
										
;==================================================================================
;	Project Name	:	
;	Applied Body	:	SPMC65P2404A
;	Firmware version:
;	Programer		:
;	Date			:	2005-2-1
;	Description		:	The Program presents an example of LCD Showing.
;						
;	Hardware Connect:	
;	Link File		:	
;	IDE Version		: 	V1.6.5	
;	BODY Version	:	V1.0.0A
;==================================================================================

.SYNTAX  6502							;Process standard 6502 addressing syntax
.LINKLIST								;Generate linklist information
.SYMBOLS								;Generate symbolic debug information
;**********************************************************************************
;*																				  *
;*      System Register Define	                                                  *
;*																				  *
;**********************************************************************************
.INCLUDE		SPMC65P2404A.inc				;Define all hardware,Registers and ports. 
;**********************************************************************************

;**********************************************************************************
;*																				  *
;*      Data memory Define	                                                      *
;*																				  *
;**********************************************************************************
.PAGE0									;Define values in the range from 00h to FFH
;LCD showing buffer
GB_ShowData			DS			1		;Showing data 
GB_ShowAddr			DS			1		;Showing data address
GB_Data				DS			11		;Showing buffer
;second watch counter register
GB_10ms				DS			1		;10ms timer base
GB_60s				DS			1		;60s timer base
GB_60m				DS			1		;60m timer base
;interrupt
GB_10msFlag			DS			1		;10ms flag
;**********************************************************************************
.DATA									;Define data storage section
;**********************************************************************************
;*																				  *
;*      	 Program Area														  *
;*																				  *
;**********************************************************************************
.CODE
;**********************************************************************************
;*																				  *
;*		Power on Reset Process													  *
;*																				  *
;**********************************************************************************
V_Reset:
		sei								;Disable interrupt
		ldx		#C_STACK_BOTTOM			;Initial stack pointer at $00FF
		txs								;Transfer to stack point
        
		jsr		F_LCD_Init
		jsr		F_Watch_Init
		
        cli
?L_Main_Loop:							;The example for test
		lda		GB_10msFlag
		cmp		#10
		bcc		?L_Main_Loop
		lda		#0
		sta		GB_10msFlag

		jsr		F_WatchShowing
		
?L_LoopExit:	
		jmp		?L_Main_Loop


;====================================================================================
;	Function:		F_Watch_Init
;	Description:	1.024ms set, varaible init
;	Input:          none
;	Output:         none
;	Destroy:		A
;	Stacks:			1
;====================================================================================
F_Watch_Init: 
	   	;------------------------------------------------------
		;1.024ms 
		lda		#C_TBASE_Div_8k			;1.024ms
		sta     P_BUZ_Ctrl
		lda		#C_INT_ITVALIE
		sta		P_INT_Ctrl2
		lda		#$FF
		sta		P_INT_Flag2

		lda		#0
		sta		GB_10msFlag
		sta		GB_10ms
		sta		GB_60s
		sta		GB_60m
		rts
;====================================================================================
;	Function:		F_WatchShowing
;	Description:	second watch counting per 10ms
;	Input:          none
;	Output:         none
;	Destroy:		A,X,Y
;	Stacks:			4
;====================================================================================
F_WatchShowing:
		sed
		lda		GB_10ms
		clc		
		adc		#1						;10ms add 1
		sta		GB_10ms
		bcc		?L_10msshow
		
		clc
		lda		GB_60s
		adc		#1						;60s add 1
		sta		GB_60s
		cmp		#$60
		bcc		?L_60sshow
		lda		#0
		sta		GB_60s
		
		clc
		lda		GB_60m
		adc		#1						;60m add 1
		sta		GB_60m		
		cmp		#$60
		bcc		?L_CouExit
		lda		#0
		sta		GB_60m		
?L_CouExit:
		cld
?L_60mshow:								;miniute showing
		lda		GB_60m	
		and		#$F
		ldy		#7
		jsr		F_LCDShow
		lda		GB_60m	
		and		#$F0
		lsr		a
		lsr		a
		lsr		a
		lsr		a
		ldy		#8
		jsr		F_LCDShow
?L_60sshow:								;second showing 
		cld
		lda		GB_60s	
		and		#$F
		ldy		#5
		jsr		F_LCDShow
		lda		GB_60s	
		and		#$F0
		lsr		a
		lsr		a
		lsr		a
		lsr		a
		ldy		#6
		jsr		F_LCDShow
?L_10msshow:							;ms showing 
		cld
		lda		GB_10ms	
		and		#$F
		ldy		#3
		jsr		F_LCDShow
		lda		GB_10ms	
		and		#$F0
		lsr		a
		lsr		a
		lsr		a
		lsr		a
		ldy		#4
		jsr		F_LCDShow
		nop
		rts		
;====================================================================================
;	Function:		F_LCD_Init
;	Description:	set IO  ;black screen  ;clear showing buffer
;	Input:          none
;	Output:         none
;	Destroy:		A,X,Y
;	Stacks:			1
;====================================================================================
F_LCD_Init:
		;---------------------------------------------
		;IO set: PB0----Data  PB1----ACK  PB2----STB
		lda		P_IOB_Attrib
		and		#%11111000
		sta		P_IOB_Attrib
		lda		P_IOB_Dir
		and		#%11111000
		ora		#%00000101
		sta		P_IOB_Dir
		lda		P_IOB_Buf
		and		#%11111000
		sta		P_IOB_Data
		sta		P_IOB_Buf
		;---------------------------------------------
		;screen black
		ldx		#%10100000
?L_Black:		
		stx		GB_ShowAddr
		lda		#0
		sta		GB_ShowData
		jsr		F_LCD
		inx
		cpx		#%10101010
		bcc		?L_Black
		
		;---------------------------------------------
		;clear showing buffer
		lda		#0
		ldx		#0
?L_BlackBuf:
		sta		GB_Data,x
		inx
		cpx		#11
		bcc		?L_BlackBuf
		rts
		
;====================================================================================
;	Function:		F_LCDShow
;	Description:	LCD Showing
;	Input:          A,Y
;	Output:         none
;	Destroy:		A,X,Y
;	Stacks:			3
;====================================================================================
F_LCDShow:
		cpy		#0
		bne		?L_Data1
		sta		GB_ShowData
		sta		GB_Data
		lda		#%10100000
		sta		GB_ShowAddr				;show data address
		jsr		F_LCD
		jmp		?L_Exit

?L_Data1:
		cpy		#1
		bne		?L_Data11
		and		#$0F
		ora		GB_Data+1
		sta		GB_ShowData
		sta		GB_Data+1
		lda		#%10100001
		sta		GB_ShowAddr				;show data address
		jsr		F_LCD
		jmp		?L_Exit
		
?L_Data11:
		cpy		#10
		bne		?L_Data
		ldx		#0
		pha
?L_Loop11:		
		inx
		cpx		#9
		beq		?L_Exit1
		pla
		rol		a
		pha
		bcc		?L_Loop11

		lda		GB_Data,x
		ora		#$80
		sta		GB_ShowData				;low 4 segment--a.b.c.d
		sta		GB_Data,x
		txa
		ora		#%10100000
		sta		GB_ShowAddr				;show data address
		jsr		F_LCD
		jmp		?L_Loop11		
?L_Exit1:
		pla
		jmp		?L_Exit

?L_Data:			
		cpy		#11
		bcs		?L_Exit
		cmp		#$11
		bcs		?L_Exit
		tax	
		pha
		lda		T_SevenSegTable,x		;showing data segment
		and		#$0F
		sta		GB_ShowData
		tya
		tax
		lda		GB_Data,x
		and		#$F0
		ora		GB_ShowData
		sta		GB_ShowData				;low 4 segment--a.b.c.d
		sta		GB_Data,x
		txa
		ora		#%10100000
		sta		GB_ShowAddr				;show data address
		jsr		F_LCD
		txa
		tay
		pla
		tax
		lda		T_SevenSegTable,x		;showing data segment
		and		#$F0
        sta		GB_ShowData
        tya
        tax
		dex
		lda		GB_Data,x
		and		#$8F
		ora		GB_ShowData
		sta		GB_ShowData
		sta		GB_Data,x
		txa
		ora		#%10100000
		sta		GB_ShowAddr				;show data address
		jsr		F_LCD
?L_Exit:		
		rts
F_LCD:		
		;--------------------------------------------
		;synchro
?L_Syn:
		set		P_IOB_Data,2	
		set		P_IOB_Data,0	
		clr		P_IOB_Data,0	
?L_s:		
		lda		P_IOB_Data
		and		#%00000010
		bne		?L_s
		set		P_IOB_Data,0	
?L_s1:		
		lda		P_IOB_Data
		and		#%00000010
		beq		?L_s1
		
		;--------------------------------------------
		;Write commend word 1010 ,address, data
		ldy		#0
?L_SendData:
		rol		GB_ShowData
		rol		GB_ShowAddr
		bcc		?L_Write0
		set		P_IOB_Data,0			;write 1
		jmp		?L_Write1
?L_Write0:
		clr		P_IOB_Data,0			;write 0
?L_Write1:
		nop
		nop
		clr		P_IOB_Data,2
?L_1:		
		lda		P_IOB_Data
		and		#%00000010
		bne		?L_1
		set		P_IOB_Data,2
?L_1q:		
		lda		P_IOB_Data
		and		#%00000010
		beq		?L_1q
		iny
		cpy		#16
		bne		?L_SendData
		rts
T_SevenSegTable:				;The segment table of lcd
		DB		%00111111		;Character '0'
		DB		%00000110		;Character '1'
		DB		%01011011		;Character '2'
		DB		%01001111		;Character '3'
		DB		%01100110		;Character '4'
		DB		%01101101		;Character '5'
		DB		%01111101		;Character '6'
		DB		%00000111		;Character '7'
		DB		%01111111		;Character '8'
		DB		%01101111		;Character '9'
		DB		%01110111		;Character 'A'
		DB		%01111100		;Character 'b'
		DB		%00111001		;Character 'C'
		DB		%01011110		;Character 'd'
		DB		%01111001		;Character 'E'
		DB		%01110001		;Character 'F'
		DB		%00000000		;Character 'black'

		
;**********************************************************************************
;*																				  *
;*      Interrupt service process                         	                      *
;*																				  *
;**********************************************************************************
V_IRQ:      
		pha
		txa
		pha
		tya
		pha
		lda		P_INT_Flag2
		and		#C_INT_ITVALIF
		beq		?L_INTExit			;time base int?no
		inc		GB_10msFlag
		lda		#C_INT_ITVALIF
		sta		P_INT_Flag2			;clear int flag
?L_INTExit:		
		pla
		tay
		pla
		tax
		pla
		rti           
		
V_NMI:
		rti
		
VECTOR:			.SECTION 		
;**********************************************************************************
;*																				  *
;*      Interrupt Vector Table													  *
;*																				  *
;**********************************************************************************
		DW		V_NMI					;Non-mask interrupt vector(no use)
		DW		V_Reset					;Reset vector
		DW		V_IRQ					;IRQ interrupt vector
;**********************************************************************************
;*																				  *
;*      End of Interrupt Vector Table											  *
;*												  								  *
;**********************************************************************************
.END

⌨️ 快捷键说明

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