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

📄 main.asm

📁 减少单片机IO资源占用,采用AD口加电阻网点方式扩展按键.含汇编代码.
💻 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-1-19
;	Description		:	The Program presents how to scan 16 Keys with the function 
;						of ADC.
;						
;	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
;**********************************************************************************
.DATA									;Define data storage section
;**********************************************************************************
;*																				  *
;*      	 Program Area														  *
;*																				  *
;**********************************************************************************
.CODE
.INCLUDE		AD_Key.asm				;Scanning 16 keys
;**********************************************************************************
;*																				  *
;*		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_Variable_Init			;Initialize variables
        jsr		F_AD_KeyInit     		;Initialize ADC function

;------------------------------------------------------
;1.024ms loop
;------------------------------------------------------
		lda		#C_TBASE_Div_8k			;1.024ms
		sta     P_BUZ_Ctrl

?L_Main_Loop:					
		ldx		#0
?L_Loop:		
		lda 	P_INT_Flag2
		and 	#C_INT_ITVALIF			;Check Timer base INT?
		beq 	?L_Loop 				;No
		lda 	#C_INT_ITVALIF
		sta 	P_INT_Flag2 			;Clear INT request flag
		inx
		cpx		#8						;8 ms coming?
		bcc		?L_Loop					;no

   		jsr		F_ADKeyx16				;Scanning 16 keys
		
		lda		GB_KeyDownFlag			;Key down?
		beq		?L_LoopExit				;No
		lda		#0
		sta		GB_KeyDownFlag			;Clear key down flag
		
		jsr		F_Light					;Show the key value
		
?L_LoopExit:	
		jmp		?L_Main_Loop
		
;**********************************************************************************
;*																				  *
;*      Interrupt service process                         	                      *
;*																				  *
;**********************************************************************************
V_IRQ:      
		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 + -