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

📄 light_init.asm

📁 系统采用SONIX单片机作为控制核心
💻 ASM
字号:
;***********************************************************************************************
;File name	:light_init.asm
;Author		:guangyu_yang
;Purpose	:Training
;Data		:2/8/2007
;Dscription	:系统初始化				
;Version:	v1.1
;Hardware&IDE:	m2 1.14
;Copyright(C).SONIX TECHNOLOGY CO.,Ltd.		   
;*************************************************************************************************
sysinit:
	clrwdr			;清狗
	call	init_oscm	;系统运行状态初始化
	call	init_ram	;ram初始化
	call	init_io		;io口初始化
	call	init_t0		;t0初始化
	ret
 /**************************************************
  Subroutine:        init_oscm                                  
  Description:       初始化震荡模式                                
  Calls:     	     N0                                              
  Variables:         N0                                  
  Input:             N0                                    
  Output:            N0                                   
*************************************************/

init_oscm:
	mov	a,#00h		;系统在正常状态运行
	b0mov	oscm,a
 	ret


 /**************************************************
  Subroutine:        init_oscm                                  
  Description:       初始化RAM,将RAM中的单元清0                          
  Calls:     	     N0                                              
  Variables:         N0                                  
  Input:             N0                                    
  Output:            N0                                   
*************************************************/
;clear BANK0

init_ram:                    		   	
        clr	Y               
	b0mov   Z , #7fh
clr_bank0:               
	clr     @YZ
	decms   Z
	jmp     clr_bank0
	clr     @YZ

;clear BAKN1
	mov	a,#1
	b0mov	Y,A
	mov	A,#0x7f
	b0mov	Z,A					;Set @YZ address from 17fh

ClrRAM20:
	clr 		@YZ				;Clear @YZ content
	decms		Z   				;z = z - 1 , skip next if z=0
	jmp 		ClrRAM20
	clr 		@YZ				;Clear address 0x100
	ret
		 
 /**************************************************
  Subroutine:        init_i/o                                  
  Description:       初始化I/O                               
  Calls:     	     N0                                              
  Variables:         N0                                  
  Input:             N0                                    
  Output:            N0                                   
*************************************************/
init_io:
;p1口初始化
	mov	a,#0ffh		;设置p1口为输入,上拉
	b0mov	p1ur,a
	mov	a,#0		;注意这里,否则读入的结果有错误。
	b0mov	p1m,a
;p2口初始化
 	mov	a,#0
	mov	p2,a	
	mov	p2m,a	

;P0口初始化
	clr	p0
	mov	a,#0
	mov	p0m,a
;P3口初始化
	clr	p3
	mov	a,#0
	mov	p3m,a
;P4口初始化,设置P4口为输出口,输出为高电平,测试的时候要观察,呆会要改为低
	mov	a,#0ffh
	mov	p4,a
	mov	p4m,a
;P5口初始化
	clr 	p5		;将P5口设为输出低
	mov	a,#0
	mov	p5m,a
	ret
 /**************************************************
  Subroutine:        init_t0                                  
  Description:       初始化T0,采用4M的外部晶振,定时10MS                             
  Calls:     	     N0                                              
  Variables:         N0                                  
  Input:             N0                                    
  Output:            N0                                   
*************************************************/
init_t0:
	b0bclr	ft0ien		;清定时中断
	b0bclr	ft0enb
	mov	a,#00h		;设置T0的分频数,64分频
	b0mov	t0m,a
	mov	a,#64h		;设置T0间隔时间的初始值10MS
	b0mov	t0c,a
	b0bset	ft0ien
	b0bset  ft0enb	
	b0bclr	ft0irq
	ret
	

⌨️ 快捷键说明

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