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

📄 t0.s

📁 基于8515的lcd显示控制程序
💻 S
字号:
	.module t0.c
	.area vector(rom, abs)
	.org 14
	rjmp _t0_isr
	.area data(ram, con, rel)
_timer_ct::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\work\avr\icc\cpld\stklcd\t0.c
	.dbsym e timer_ct _timer_ct s
_timer_set::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\work\avr\icc\cpld\stklcd\t0.c
	.dbsym e timer_set _timer_set s
	.area text(rom, con, rel)
	.dbfile E:\work\avr\icc\cpld\stklcd\t0.c
	.dbfunc e T0_init _T0_init fV
	.even
_T0_init::
	.dbline -1
	.dbline 62
; //
; //	File Name:		t0.c
; //
; //	Title:			Internal timer 0 implementation
; //
; //	Description:	
; //
; //	Creation Date:	2/6/00 5:31:06 PM
; //
; //	By:				A.C. Verbeck
; //
; //	This file is subject to the terms and conditions of the GNU General Public
; //	License.  See the file COPYING in the main directory of this archive
; //	for more details.
; //
; 
; #include <io8515v.h>
; #include <stdio.h>
; #include <macros.h>
; 
; #include "Basetype.h"
; #include "t0.h"
; 
; #pragma interrupt_handler	t0_isr:8;
; 
; //
; //	Local defines
; //
; #define		MAX_CT		0xFF		//	Max count that can be assigned
; #define		_1MS		0x3f		//	1.008mS delay time
; #define		_2MS		0x7D		//	2mS delay time (exact)
; #define		_4MS		0xFA		//	4mS delay time (exact)
; 
; //
; //	Local data
; //
; UInt16	timer_ct	= 0;			//	Current timer count
; UInt16	timer_set	= 0;			//	Timer time out value
; 
; //
; //	Local functions
; //
; static void t0_isr(void);
; 
; //
; //	Function Name:
; //		T0_init
; //
; //	Description:
; //		Initialize internal timer 0.
; //		- set divider to ck/64
; //		- set count to 63
; //		- this gives a 1.008mS interrupt interval (992Hz)
; //
; //	Parameters:
; //		(none)
; //
; //	Returns:
; //		(nothing)
; //
; void T0_init(void)
; {
	.dbline 63
; 	CLI();									//	Interrupts OFF
	cli
	.dbline 64
; 	TCCR0 = 0x03;							//	Set divider to ck/64
	ldi R24,3
	out 0x33,R24
	.dbline 65
; 	TCNT0 = (MAX_CT-_1MS);					//	Set the time out
	ldi R24,192
	out 0x32,R24
	.dbline 66
; 	TIMSK |= 0x02;							//	Enable the interrupt
	in R24,0x39
	ori R24,2
	out 0x39,R24
	.dbline 68
; 
; 	timer_ct = 0;							//	Init the soft timer
	clr R2
	clr R3
	sts _timer_ct+1,R3
	sts _timer_ct,R2
	.dbline 69
; 	SEI();									//	Interrupts ON
	sei
	.dbline -2
	.dbline 70
; } 
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_clear _T0_clear fV
	.even
_T0_clear::
	.dbline -1
	.dbline 73
; 
; void T0_clear(void)
; {
	.dbline 74
; 	timer_ct = 0;
	clr R2
	clr R3
	sts _timer_ct+1,R3
	sts _timer_ct,R2
	.dbline -2
	.dbline 75
; }
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_set _T0_set fV
;       time_out -> R16,R17
	.even
_T0_set::
	.dbline -1
	.dbline 94
; 
; 
; //
; //	Function Name:
; //		T0_set
; //
; //	Description:
; //		Set the next timeout for the internal timer 0.
; //		Note that this code works even if the timer
; //		"rolls over".
; //
; //	Parameters:
; //		UInt16	time_out - the wakeup time
; //
; //	Returns:
; //		(nothing)
; //
; void T0_set(UInt16 time_out)
; {
	.dbline 95
; 	CLI();									//	Interrupts OFF
	cli
	.dbline 96
; 	timer_ct  = 0;							//	Clear the timer count to 0
	clr R2
	clr R3
	sts _timer_ct+1,R3
	sts _timer_ct,R2
	.dbline 97
; 	timer_set = time_out;					//	Set the new timeout
	sts _timer_set+1,R17
	sts _timer_set,R16
	.dbline 98
; 	SEI();									//	Interrupts ON
	sei
	.dbline -2
	.dbline 99
; }
L3:
	.dbline 0 ; func end
	ret
	.dbsym r time_out 16 s
	.dbend
	.dbfunc e T0_get _T0_get fs
	.even
_T0_get::
	.dbline -1
	.dbline 101
; UInt16 T0_get(void)
; {
	.dbline 102
; 	return timer_ct;
	lds R16,_timer_ct
	lds R17,_timer_ct+1
	.dbline -2
L4:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_enable _T0_enable fV
	.even
_T0_enable::
	.dbline -1
	.dbline 107
; }
; 
; 
; void T0_enable(void)
; {
	.dbline 108
; 	TIMSK |= 0x02;							//	Enable the interrupt
	in R24,0x39
	ori R24,2
	out 0x39,R24
	.dbline -2
	.dbline 109
; }
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_disable _T0_disable fV
	.even
_T0_disable::
	.dbline -1
	.dbline 111
; void T0_disable(void)
; {
	.dbline 112
; 	TIMSK &= ~0x02;							//	Disable the interrupt
	in R24,0x39
	andi R24,253
	out 0x39,R24
	.dbline -2
	.dbline 113
; }
L6:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_sleep _T0_sleep fV
;       time_out -> R16,R17
	.even
_T0_sleep::
	.dbline -1
	.dbline 116
; 
; void T0_sleep(UInt16 time_out)
; {
	.dbline 117
; 	CLI();									//	Interrupts OFF
	cli
	.dbline 118
; 	timer_ct  = 0;							//	Clear the timer count to 0
	clr R2
	clr R3
	sts _timer_ct+1,R3
	sts _timer_ct,R2
	.dbline 119
; 	timer_set = time_out;					//	Set the new timeout
	sts _timer_set+1,R17
	sts _timer_set,R16
	.dbline 120
; 	SEI();									//	Interrupts ON
	sei
L8:
	.dbline 121
L9:
	.dbline 121
; 	while (timer_ct != timer_set);			//	Just wait here
	lds R2,_timer_set
	lds R3,_timer_set+1
	lds R4,_timer_ct
	lds R5,_timer_ct+1
	cp R4,R2
	cpc R5,R3
	brne L8
	.dbline -2
	.dbline 122
; }
L7:
	.dbline 0 ; func end
	ret
	.dbsym r time_out 16 s
	.dbend
	.dbfunc s t0_isr _t0_isr fV
	.even
_t0_isr:
	st -y,R24
	st -y,R25
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 125
; 
; static void t0_isr(void)
; {
	.dbline 126
; 	++timer_ct;								//	Boost the software timer
	lds R24,_timer_ct
	lds R25,_timer_ct+1
	adiw R24,1
	sts _timer_ct+1,R25
	sts _timer_ct,R24
	.dbline 127
; 	TCNT0 = (MAX_CT-_1MS);					//	Set the time out
	ldi R24,192
	out 0x32,R24
	.dbline -2
	.dbline 128
; }
L11:
	ld R24,y+
	out 0x3f,R24
	ld R25,y+
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend

⌨️ 快捷键说明

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