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

📄 initialize.asm

📁 应用松翰母体写的一款电磁炉
💻 ASM
字号:
;**********************************************
;Name	:RAMInitial
;Function:clr bank0~bank1
;Input  :
;Output	:
;Register Used:
;***********************************************
RAMInitial:
	clr	y
	mov	a,#7fh
	b0mov	z,a
Clrbank0:
	clr	@YZ				;Clear @YZ content
	decms	Z  				;z = z - 1 , skip next if z=0
	jmp	Clrbank0
	clr 	@YZ				;Clear address 0x00
;-----
;preset some constant

	mov_	timer1s,#100		;1s
	mov_	timer1m,#60		;1m
	mov_	timer2h,#120		;2h
	mov_	combuf,#11111111b	;set all com high level
	mov_	pwmpulsebuf,#10		;set initialize pwm pusle=10/32

	ret
;**********************************************
;Name	:PortInitial
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
PortInitial:

	mov	a,#0ffh	
	mov	p2m,a		;set p2 is output port
	mov	p2,a		;set all p2 pin high level

	mov	a,#11110000b	;set p4.7~p4.4 is output,others is input
	mov	p4m,a		
	mov	a,#11110000b
	mov	p4,a
	clr	p4ur
	
	mov	a,#11111111b
	mov	p5m,a		;set p5 is output except p5.1
	mov	a,#11001011b
	mov	p5,a

	ret

;**********************************************
;Name	:SysInitial
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
SysInitial:

	bclr	ftc0ien			;dis t0 int
	bclr	ftc0enb			;stop t0 count
	mov	A,#00100100B		;//f0=fcpu/64
	b0mov	Tc0M,A
	mov	A,#100			;//10ms constant  for  f0=1mips/64
	b0mov	Tc0C,A
	b0bset	FTc0ENB			; Enable TIMER0
	bset	FTc0IEN			; Enable T0 interrupt
	bclr	ftc0irq			; CLEAR TIMER0 INTERRUPT FLAG
;----
;初始化pwm
	bclr	ftc1ien			;dis t1 int
	clr	t0m			;ftc1=fcpu
	clr	tc1c
	mov	a,#01100101b		
	mov	tc1m,a			;set pwm=32 duty fpwm=62.5k
	bclr	ftc1out
	bclr	fpwm1out
	bclr	ftc1enb			;stop t1 count
;----
	clr	ADM
	b0bset	FADENB			;enable adc
	mov_	ADR,#01010000b		;select 12 bit ADC,Fcpu/2=128us
;----
	bset	poweronflag		;通电标志	
	b0bset	FGIE			;//enable Interrupt gain
	ret

;**********************************************
;Name	:Pdelay
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
Pdelay:
	mov	a,#0ffh
	mov	var1,a
loop10:
	mov	a,#0ffh
	mov	var2,a
loop11:
	decms	var2
	jmp	loop11			;power on delay
	decms	var1
	jmp	loop10
	ret

⌨️ 快捷键说明

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