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

📄 app.s

📁 AVR单片机C语言程序设计实例精粹
💻 S
字号:
	.module app.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.dbfunc e Hardware_Init _Hardware_Init fV
	.even
_Hardware_Init::
	.dbline -1
	.dbline 25
; //***************************************************************
; // File Name : Gpio.c
; // Author    : Steaven
; // Created   : 2008-06-09
; // Modified  : 
; // Revision  : V0.0
; //***************************************************************
; 
; #include "iom16v.h" 
; #include "DataType.h"
; #include "app.h"
; 
; //local function declaration
; void Gpio_Init(void);
; void Timer0_Init(void);
; void Interrupt_Init(void);
; 
; //***************************************************************
; // Function    : Hardware_Init
; // Input       : none
; // Output      : none
; // Description : ATmega16 Hardware Initialization
; //***************************************************************
; void Hardware_Init(void)
; {
	.dbline 26
;     Gpio_Init();
	xcall _Gpio_Init
	.dbline 27
;     Timer0_Init();
	xcall _Timer0_Init
	.dbline 28
; 	Interrupt_Init();
	.dbline -2
	.dbline 29
; }
L1:
	.dbline 0 ; func end
	xjmp _Interrupt_Init
	.dbend
	.dbfunc e Gpio_Init _Gpio_Init fV
	.even
_Gpio_Init::
	.dbline -1
	.dbline 38
; 
; //***************************************************************
; // Function    : Gpio_Init
; // Input       : none
; // Output      : none
; // Description : ATmega16 GPIO Initialization
; //***************************************************************
; void Gpio_Init(void)
; {
	.dbline 39
;     DDRA  = 0xFF; //端口A设置为输出
	ldi R24,255
	out 0x1a,R24
	.dbline 40
;     PORTA = 0x00; //初始化输出0
	clr R2
	out 0x1b,R2
	.dbline 41
;     DDRB  = 0x0F; //端口B设置为输出
	ldi R24,15
	out 0x17,R24
	.dbline 42
;     PORTB = 0xF0; //初始化输出0
	ldi R24,240
	out 0x18,R24
	.dbline 43
;     DDRC  = 0xFF; //端口C设置为输出
	ldi R24,255
	out 0x14,R24
	.dbline 44
;     PORTC = 0x00; //初始化输出0
	out 0x15,R2
	.dbline 45
;     DDRD  = 0xFF; //端口D设置为输出
	out 0x11,R24
	.dbline 46
;     PORTD = 0x00; //初始化输出0
	out 0x12,R2
	.dbline -2
	.dbline 47
; }
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Timer0_Init _Timer0_Init fV
	.even
_Timer0_Init::
	.dbline -1
	.dbline 56
; 
; //***************************************************************
; // Function    : Timer0_Init
; // Input       : none
; // Output      : none
; // Description : ATmega16 Timer0 Initialization,10ms Interval
; //***************************************************************
; void Timer0_Init(void)
; {
	.dbline 57
; 	TCCR0 = 0x0D;   //1024 division,8M/1024,CTC Mode
	ldi R24,13
	out 0x33,R24
	.dbline 58
; 	TCNT0 = 0x00;   //Clear Counter
	clr R2
	out 0x32,R2
	.dbline 59
; 	OCR0  = 78;     //78 * 1024/8M = 10ms 
	ldi R24,78
	out 0x3c,R24
	.dbline 60
; 	TIMSK |= 0x02;  //Enable OCIE0
	in R24,0x39
	ori R24,2
	out 0x39,R24
	.dbline 61
; 	TIFR  |= 0x02;  //Clear OCIF0
	in R24,0x38
	ori R24,2
	out 0x38,R24
	.dbline -2
	.dbline 62
; }
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Interrupt_Init _Interrupt_Init fV
	.even
_Interrupt_Init::
	.dbline -1
	.dbline 71
; 
; //***************************************************************
; // Function    : Interrupt_Init
; // Input       : none
; // Output      : none
; // Description : ATmega16 Interrupt Initialization
; //***************************************************************
; void Interrupt_Init(void)
; {
	.dbline 72
; 	SREG |= 0x80;   //Enable Global Interrupt
	bset 7
	.dbline -2
	.dbline 73
; }
L4:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
L6:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.dbfunc e Get_Key0 _Get_Key0 fc
	.dbsym s Key_Flag L6 c
	.even
_Get_Key0::
	.dbline -1
	.dbline 82
; 
; //***************************************************************
; // Function    : Get_Key0/1/2/3
; // Input       : none
; // Output      : Key Press Status
; // Description : Key Press Status Check
; //***************************************************************
; INT8U Get_Key0(void)
; {
	.dbline 84
; 	static INT8U Key_Flag = 0;
; 	if(Key_Flag == 0)
	lds R2,L6
	tst R2
	brne L7
	.dbline 85
; 	{
	.dbline 86
; 		if((PINB & 0x10) == 0x00)
	sbic 0x16,4
	rjmp L8
	.dbline 87
; 		{
	.dbline 88
; 			Key_Flag = 1;
	ldi R24,1
	sts L6,R24
	.dbline 89
; 		}
	.dbline 90
; 	}
	xjmp L8
L7:
	.dbline 91
; 	else if(Key_Flag == 1)
	lds R24,L6
	cpi R24,1
	brne L11
	.dbline 92
; 	{
	.dbline 93
; 		if((PINB & 0x10) == 0x10)
	in R24,0x16
	andi R24,16
	cpi R24,16
	brne L13
	.dbline 94
; 		{
	.dbline 95
; 			Key_Flag = 0;
	clr R2
	sts L6,R2
	.dbline 96
; 			return(true);
	ldi R16,1
	xjmp L5
L13:
	.dbline 98
; 		}
; 	}
L11:
L8:
	.dbline 99
; 	return(false);
	clr R16
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
L16:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.dbfunc e Get_Key1 _Get_Key1 fc
	.dbsym s Key_Flag L16 c
	.even
_Get_Key1::
	.dbline -1
	.dbline 103
; }
; 
; INT8U Get_Key1(void)
; {
	.dbline 105
; 	static INT8U Key_Flag = 0;
; 	if(Key_Flag == 0)
	lds R2,L16
	tst R2
	brne L17
	.dbline 106
; 	{
	.dbline 107
; 		if((PINB & 0x20) == 0x00)
	sbic 0x16,5
	rjmp L18
	.dbline 108
; 		{
	.dbline 109
; 			Key_Flag = 1;
	ldi R24,1
	sts L16,R24
	.dbline 110
; 		}
	.dbline 111
; 	}
	xjmp L18
L17:
	.dbline 112
; 	else if(Key_Flag == 1)
	lds R24,L16
	cpi R24,1
	brne L21
	.dbline 113
; 	{
	.dbline 114
; 		if((PINB & 0x20) == 0x20)
	in R24,0x16
	andi R24,32
	cpi R24,32
	brne L23
	.dbline 115
; 		{
	.dbline 116
; 			Key_Flag = 0;
	clr R2
	sts L16,R2
	.dbline 117
; 			return(true);
	ldi R16,1
	xjmp L15
L23:
	.dbline 119
; 		}
; 	}
L21:
L18:
	.dbline 120
; 	return(false);
	clr R16
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
L26:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.dbfunc e Get_Key2 _Get_Key2 fc
	.dbsym s Key_Flag L26 c
	.even
_Get_Key2::
	.dbline -1
	.dbline 124
; }
; 
; INT8U Get_Key2(void)
; {
	.dbline 126
; 	static INT8U Key_Flag = 0;
; 	if(Key_Flag == 0)
	lds R2,L26
	tst R2
	brne L27
	.dbline 127
; 	{
	.dbline 128
; 		if((PINB & 0x40) == 0x00)
	sbic 0x16,6
	rjmp L28
	.dbline 129
; 		{
	.dbline 130
; 			Key_Flag = 1;
	ldi R24,1
	sts L26,R24
	.dbline 131
; 		}
	.dbline 132
; 	}
	xjmp L28
L27:
	.dbline 133
; 	else if(Key_Flag == 1)
	lds R24,L26
	cpi R24,1
	brne L31
	.dbline 134
; 	{
	.dbline 135
; 		if((PINB & 0x40) == 0x40)
	in R24,0x16
	andi R24,64
	cpi R24,64
	brne L33
	.dbline 136
; 		{
	.dbline 137
; 			Key_Flag = 0;
	clr R2
	sts L26,R2
	.dbline 138
; 			return(true);
	ldi R16,1
	xjmp L25
L33:
	.dbline 140
; 		}
; 	}
L31:
L28:
	.dbline 141
; 	return(false);
	clr R16
	.dbline -2
L25:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
L36:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\字符型LCD显示应用设计\app.c
	.dbfunc e Get_Key3 _Get_Key3 fc
	.dbsym s Key_Flag L36 c
	.even
_Get_Key3::
	.dbline -1
	.dbline 145
; }
; 
; INT8U Get_Key3(void)
; {
	.dbline 147
; 	static INT8U Key_Flag = 0;
; 	if(Key_Flag == 0)
	lds R2,L36
	tst R2
	brne L37
	.dbline 148
; 	{
	.dbline 149
; 		if((PINB & 0x80) == 0x00)
	sbic 0x16,7
	rjmp L38
	.dbline 150
; 		{
	.dbline 151
; 			Key_Flag = 1;
	ldi R24,1
	sts L36,R24
	.dbline 152
; 		}
	.dbline 153
; 	}
	xjmp L38
L37:
	.dbline 154
; 	else if(Key_Flag == 1)
	lds R24,L36
	cpi R24,1
	brne L41
	.dbline 155
; 	{
	.dbline 156
; 		if((PINB & 0x80) == 0x80)
	in R24,0x16
	andi R24,128
	cpi R24,128
	brne L43
	.dbline 157
; 		{
	.dbline 158
; 			Key_Flag = 0;
	clr R2
	sts L36,R2
	.dbline 159
; 			return(true);
	ldi R16,1
	xjmp L35
L43:
	.dbline 161
; 		}
; 	}
L41:
L38:
	.dbline 162
; 	return(false);
	clr R16
	.dbline -2
L35:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Buzzer_ON _Buzzer_ON fV
	.even
_Buzzer_ON::
	.dbline -1
	.dbline 172
; }
; 
; //***************************************************************
; // Function    : Buzzer_ON/OFF
; // Input       : none
; // Output      : none
; // Description : Buzzer ON/OFF Control
; //***************************************************************
; void Buzzer_ON(void)
; {
	.dbline 173
; 	PORTB |= 0x08;
	sbi 0x18,3
	.dbline -2
	.dbline 174
; }
L45:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Buzzer_OFF _Buzzer_OFF fV
	.even
_Buzzer_OFF::
	.dbline -1
	.dbline 177
; 
; void Buzzer_OFF(void)
; {
	.dbline 178
; 	PORTB &= ~0x08;
	cbi 0x18,3
	.dbline -2
	.dbline 179
; }
L46:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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