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

📄 -ͦ

📁 手把手教你学AVR单片机C程序设计实验程序
💻
📖 第 1 页 / 共 5 页
字号:
	.module icc17-1.c
	.area lit(rom, con, rel)
_STR::
	.byte 't,49,58,32,32,47,32,32,'t,50,58,32,32,47,32,32
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e STR _STR A[16:16]kc
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
_year::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e year _year i
_month::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e month _month c
_date::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e date _date c
_hour::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e hour _hour c
_minute::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e minute _minute c
_second::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e second _second c
_set_hour1::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e set_hour1 _set_hour1 c
_set_minute1::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e set_minute1 _set_minute1 c
_set_hour2::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e set_hour2 _set_hour2 c
_set_minute2::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e set_minute2 _set_minute2 c
_ReceverCnt::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e ReceverCnt _ReceverCnt c
_ReceverEndFlag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e ReceverEndFlag _ReceverEndFlag c
_Flag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e Flag _Flag c
_Flag_1820Error::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbsym e Flag_1820Error _Flag_1820Error c
	.area text(rom, con, rel)
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1\icc17-1.c
	.dbfile D:\文稿\手把手教你学AVR单片机C程序设计\第17章~1\第17章实验程序\icc17-1/lcd.c
	.dbfunc e lcd_busy _lcd_busy fV
;            val -> R16
	.even
_lcd_busy::
	.dbline -1
	.dbline 3
; #include <iom16v.h>
; #include <macros.h>
; #define uchar unsigned char	
	.dbline 5
; #define uint unsigned int
; uchar col,row,cbyte;  /*列x,行(页)y,输出数据 */
	cbi 0x18,0
	.dbline 5
	nop
	.dbline 5
	nop
	.dbline 6
; uchar const STR[16]="t1:  /  t2:  /  ";
	sbi 0x18,1
	.dbline 6
	nop
	.dbline 6
	nop
	.dbline 7
; uint year=0;
	clr R2
	out 0x1b,R2
	xjmp L3
L2:
	.dbline 9
; uchar month=0,date=0,hour=0,minute=0,second=0;
; uchar set_hour1=0,set_minute1=0;
	.dbline 10
; uchar set_hour2=0,set_minute2=0;
	sbi 0x18,2
	.dbline 10
	nop
	.dbline 10
	nop
	.dbline 11
; uchar temp;
	clr R2
	out 0x1a,R2
	.dbline 12
; uchar ReceverCnt=0,ReceverEndFlag=0,Flag=0;
	in R16,0x19
	.dbline 13
; uchar a[12],b[4],c[4],d[2];
	cpi R16,128
	brsh L5
	.dbline 13
	xjmp L4
L5:
	.dbline 14
	cbi 0x18,2
	.dbline 14
	nop
	.dbline 14
	nop
	.dbline 15
L3:
	.dbline 8
	xjmp L2
L4:
	.dbline 16
; uchar e[4];
; uchar temh,teml; 
; uchar sign;
	ldi R24,255
	out 0x1a,R24
	.dbline 17
; uchar Flag_1820Error=0;
	cbi 0x18,2
	.dbline 17
	nop
	.dbline 17
	nop
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r val 16 c
	.dbend
	.dbfunc e wcode _wcode fV
;          sel_r -> y+4
;          sel_l -> R22
;              c -> R20
	.even
_wcode::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	.dbline -1
	.dbline 21
; #include"head.h"
; #include"lcd.c"
; #include"display_time.c"
; #include"recever.c"
	.dbline 22
; #include"ds18b20.c"
	cpi R22,1
	brne L8
	.dbline 22
	sbi 0x18,3
	xjmp L9
L8:
	.dbline 23
; /*----------------ATMEGA16L初始化子函数。-----------------------*/
	cbi 0x18,3
L9:
	.dbline 24
; void m16_init(void)
	nop
	.dbline 24
	nop
	.dbline 25
; {
	ldd R24,y+4
	cpi R24,1
	brne L10
	.dbline 25
	sbi 0x18,4
	xjmp L11
L10:
	.dbline 26
; PORTA=0x00;
	cbi 0x18,4
L11:
	.dbline 27
; DDRA=0xff;
	nop
	.dbline 27
	nop
	.dbline 28
; PORTB=0x80;
	xcall _lcd_busy
	.dbline 29
; DDRB=0xff;
	cbi 0x18,0
	.dbline 29
	nop
	.dbline 29
	nop
	.dbline 30
; DDRC=0xff; 
	cbi 0x18,1
	.dbline 30
	nop
	.dbline 30
	nop
	.dbline 31
; PORTC=0xff; 
	out 0x1b,R20
	.dbline 32
; PORTD = 0x7f; 			//36
	sbi 0x18,2
	.dbline 32
	nop
	.dbline 32
	nop
	.dbline 33
; DDRD  = 0x82; 
	cbi 0x18,2
	.dbline 33
	nop
	.dbline 33
	nop
	.dbline -2
L7:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l sel_r 4 c
	.dbsym r sel_l 22 c
	.dbsym r c 20 c
	.dbend
	.dbfunc e wdata _wdata fV
;          sel_r -> y+4
;          sel_l -> R22
;              c -> R20
	.even
_wdata::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	.dbline -1
	.dbline 37
; timer1_init();
; uart0_init();
; }
; /***********************************/
	.dbline 38
; void uart0_init(void) 			//40
	cpi R22,1
	brne L13
	.dbline 38
	sbi 0x18,3
	xjmp L14
L13:
	.dbline 39
; {							//41
	cbi 0x18,3
L14:
	.dbline 40
;  UCSRB = 0x00; 			//42
	nop
	.dbline 40
	nop
	.dbline 41
;  UCSRA = 0x82;				//43
	ldd R24,y+4
	cpi R24,1
	brne L15
	.dbline 41
	sbi 0x18,4
	xjmp L16
L15:
	.dbline 42
;  UCSRC = 0x06;				//44
	cbi 0x18,4
L16:
	.dbline 43
;  UBRRL = 0x67; 				//45
	nop
	.dbline 43
	nop
	.dbline 44
;  UBRRH = 0x00; 			//46
	xcall _lcd_busy
	.dbline 45
;  UCSRB = 0x98;				//47
	sbi 0x18,0
	.dbline 45
	nop
	.dbline 45
	nop
	.dbline 46
; }							//48
	cbi 0x18,1
	.dbline 46
	nop
	.dbline 46
	nop
	.dbline 47
; 
	out 0x1b,R20
	.dbline 48
; /******************************/
	sbi 0x18,2
	.dbline 48
	nop
	.dbline 48
	nop
	.dbline 49
; void timer1_init(void)
	cbi 0x18,2
	.dbline 49
	nop
	.dbline 49
	nop
	.dbline -2
L12:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l sel_r 4 c
	.dbsym r sel_l 22 c
	.dbsym r c 20 c
	.dbend
	.dbfunc e lw _lw fV
;             dd -> y+5
;              y -> R22
;              x -> R20
	.even
_lw::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	sbiw R28,1
	.dbline -1
	.dbline 53
; {
;  CLI();
;  TCCR1B = 0x00; //stop
;  TCNT1H = 0xE1; //setup
	.dbline 54
;  TCNT1L = 0x7C;
	cpi R20,64
	brlo L18
	.dbline 55
;  TCCR1A = 0x00;
	.dbline 55
	mov R18,R22
	mov R16,R20
	subi R16,64
	xcall _set_xy
	.dbline 56
;  TCCR1B = 0x05; //start Timer
	ldi R24,1
	std y+0,R24
	clr R18
	ldd R16,y+5
	xcall _wdata
	.dbline 56
	xjmp L19
L18:
	.dbline 58
	.dbline 58
	mov R18,R22
	mov R16,R20
	xcall _set_xy
	.dbline 59
	clr R2
	std y+0,R2
	ldi R18,1
	ldd R16,y+5
	xcall _wdata
	.dbline 59
L19:
	.dbline -2
L17:
	adiw R28,1
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l dd 5 c
	.dbsym r y 22 c
	.dbsym r x 20 c
	.dbend
	.dbfunc e set_startline _set_startline fV
;              i -> R20
	.even
_set_startline::
	xcall push_gset1
	mov R20,R16
	sbiw R28,1
	.dbline -1
	.dbline 63
;  TIMSK = 0x04; 
;  SEI();
; }
; /*************主函数*************/
; void main(void)	
; {
;   uchar loop,tempday;	
	.dbline 64
;   m16_init();			
	subi R20,64    ; addi 192
	.dbline 65
;   lcd_init();	
	ldi R24,1
	std y+0,R24
	ldi R18,1
	mov R16,R20
	xcall _wcode
	.dbline -2
L20:
	adiw R28,1
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e set_xy _set_xy fV
;              y -> R20
;              x -> R22
	.even
_set_xy::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	sbiw R28,1
	.dbline -1
	.dbline 69
;   display_tu(1);
;   Delay_nms(3000);
;   display_tu(0);	
;   Delay_nms(3000);
	.dbline 70
;   lcd_init();	
	subi R22,192    ; addi 64
	.dbline 71
;   display_chinese();
	subi R20,72    ; addi 184
	.dbline 72
;   Delay_nms(5000);
	ldi R24,1
	std y+0,R24
	ldi R18,1
	mov R16,R22
	xcall _wcode
	.dbline 73
;   lcd_init();	
	ldi R24,1
	std y+0,R24
	ldi R18,1
	mov R16,R20
	xcall _wcode
	.dbline -2
L21:
	adiw R28,1
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r y 20 c
	.dbsym r x 22 c
	.dbend
	.dbfunc e dison_off _dison_off fV
;              o -> R20
	.even
_dison_off::
	xcall push_gset1
	mov R20,R16
	sbiw R28,1
	.dbline -1
	.dbline 77
;  //***********************************/  
; display_hz(4,0,0,1,nian);
; display_hz(8,0,0,1,yue);
; display_hz(12,0,0,1,ri);
	.dbline 78
; display_hz(4,2,0,1,shi);
	subi R20,194    ; addi 62
	.dbline 79
; display_hz(8,2,0,1,fen);
	ldi R24,1
	std y+0,R24
	ldi R18,1
	mov R16,R20
	xcall _wcode
	.dbline -2
L22:
	adiw R28,1
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r o 20 c
	.dbend
	.dbfunc e reset _reset fV
	.even
_reset::
	.dbline -1
	.dbline 83
; display_hz(12,2,0,1,miao);
; /**********************************/
; col=0;row=4;Putstr(STR,16);
; /***********************************/
	.dbline 84
; for(loop=0;loop<5;loop++)
	cbi 0x18,5
	.dbline 85
; {display_hz(2*loop,6,loop,1,temperature);}
	ldi R16,10
	ldi R17,0
	xcall _Delay_nms
	.dbline 86
; display_hz(14,6,0,1,du);
	sbi 0x18,5
	.dbline 87
; /***********************************/
	ldi R16,10
	ldi R17,0
	xcall _Delay_nms
	.dbline -2
L23:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e lcd_init _lcd_init fV
;              y -> R20
;              x -> R22
	.even
_lcd_init::
	xcall push_gset2
	sbiw R28,1
	.dbline -1
	.dbline 91
;  for(;;)				
;  { 
;   if(Flag_1820Error==0)read_temperature();
;   tempday=conv(year,month);
	.dbline 92
;   if(second>59){second=0;minute++;}
	xcall _reset
	.dbline 93
;   if(minute>59){minute=0;hour++;}
	clr R16
	xcall _set_startline
	.dbline 94
;   if(hour>23){hour=0;date++;}
	clr R16
	xcall _dison_off
	.dbline 95
;   if(date>tempday){date=1;month++;}
	clr R20
	xjmp L28
L25:
	.dbline 96
;   if(month>12){month=1;year++;}
	.dbline 97
	clr R22
	xjmp L32
L29:
	.dbline 97
	clr R2
	std y+0,R2
	mov R18,R20
	mov R16,R22
	xcall _lw
L30:
	.dbline 97
	inc R22
L32:
	.dbline 97
	cpi R22,128
	brlo L29
	.dbline 98
L26:
	.dbline 95
	inc R20
L28:
	.dbline 95
	cpi R20,8
	brlo L25
	.dbline 99
;   if(year>9999)year=0;
;   dis_time();
;   //----------------------------------
	ldi R16,1
	xcall _dison_off
	.dbline -2
L24:
	adiw R28,1
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r y 20 c
	.dbsym r x 22 c
	.dbend
	.dbfunc e display_hz _display_hz fV
;             dx -> R20
;              i -> R22
;              p -> R10,R11
;             fb -> R12
;              n -> R14
;             yy -> y+13
;             xx -> y+11
	.even
_display_hz::
	xcall push_arg4
	xcall push_gset5
	sbiw R28,1
	ldd R14,y+15
	ldd R12,y+17
	ldd R10,y+19
	ldd R11,y+20
	.dbline -1
	.dbline 103
;   if(d[0]==1)
;   {
;     if((hour==set_hour1)&&(minute==set_minute1))Led_On;
;   }
	.dbline 105
;   //----------------------------------
;   if(d[1]==1)
	clr R22
	xjmp L37
L34:
	.dbline 106
;   {
	.dbline 106
	ldi R24,32
	mul R24,R14
	movw R2,R0
	ldi R24,2
	mul R24,R22
	movw R30,R0
	add R30,R2
	adc R31,R3
	add R30,R10
	adc R31,R11
	lpm R20,Z
	.dbline 107
;     if((hour==set_hour2)&&(minute==set_minute2))Led_Off;
	tst R12
	breq L38
	.dbline 107
	mov R2,R20
	clr R3
	ldi R20,255
	sub R20,R2
	sbc R21,R3
L38:
	.dbline 108
;   }
	std y+0,R20
	ldd R18,y+13
	ldi R24,8
	ldd R0,y+11
	mul R24,R0
	mov R16,R0
	add R16,R22
	xcall _lw
	.dbline 109
;   //----------------------------------
	ldi R24,32
	mul R24,R14
	movw R2,R0
	ldi R24,2
	mul R24,R22
	movw R30,R0
	adiw R30,1
	add R30,R2
	adc R31,R3
	add R30,R10
	adc R31,R11
	lpm R20,Z
	.dbline 110
;   if(ReceverEndFlag>0)
	tst R12
	breq L40
	.dbline 110
	mov R2,R20
	clr R3
	ldi R20,255
	sub R20,R2
	sbc R21,R3
L40:
	.dbline 111
	std y+0,R20
	ldd R18,y+13
	subi R18,255    ; addi 1
	ldi R24,8
	ldd R0,y+11
	mul R24,R0
	mov R16,R0
	add R16,R22
	xcall _lw
	.dbline 112
L35:
	.dbline 105
	inc R22
L37:
	.dbline 105
	cpi R22,16
	brsh X0
	xjmp L34
X0:
	.dbline -2
L33:
	adiw R28,1
	xcall pop_gset5
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r dx 20 c
	.dbsym r i 22 c
	.dbsym r p 10 pkc
	.dbsym r fb 12 c
	.dbsym r n 14 c
	.dbsym l yy 13 c
	.dbsym l xx 11 c
	.dbend
	.dbfunc e display_chinese _display_chinese fV
;           loop -> R20
	.even
_display_chinese::
	xcall push_gset1
	sbiw R28,6
	.dbline -1
	.dbline 117
;    {
;    ReceverEndFlag=0;	
;    uart0_send(0x4f);
;    uart0_send(0x4b);	
;    mov();
;    }		
;  }								
	.dbline 119
; }								
; /*************************************/
	clr R20
	xjmp L46
L43:
	.dbline 120
	.dbline 120
	ldi R24,<_chinese
	ldi R25,>_chinese
	std y+5,R25
	std y+4,R24
	ldi R24,1
	std y+2,R24
	std y+0,R20
	clr R18
	ldi R24,2
	mul R24,R20
	mov R16,R0
	xcall _display_hz
	.dbline 120
L44:
	.dbline 119
	inc R20
L46:
	.dbline 119
	cpi R20,8
	brlo L43
	.dbline 122
; void Delay_1ms(void)		//1mS延时子函数
; { uint i;
;  for(i=1;i<(uint)(xtal*143-2);i++)
	clr R20
	xjmp L50
L47:
	.dbline 123
	.dbline 123
	ldi R24,<_chinese
	ldi R25,>_chinese
	std y+5,R25
	std y+4,R24
	ldi R24,1
	std y+2,R24
	mov R24,R20
	subi R24,248    ; addi 8
	std y+0,R24
	ldi R18,2
	ldi R24,2
	mul R24,R20
	mov R16,R0
	xcall _display_hz
	.dbline 123
L48:
	.dbline 122
	inc R20
L50:
	.dbline 122
	cpi R20,8
	brlo L47
	.dbline 126
; ;
; }
; //====================================
; void Delay_nms(uint n)		//n*1mS延时子函数
	clr R20
	xjmp L54
L51:
	.dbline 127
	.dbline 127
	ldi R24,<_chinese
	ldi R25,>_chinese
	std y+5,R25
	std y+4,R24
	ldi R24,1
	std y+2,R24
	mov R24,R20
	subi R24,240    ; addi 16
	std y+0,R24
	ldi R18,4
	ldi R24,2
	mul R24,R20
	mov R16,R0
	xcall _display_hz
	.dbline 127
L52:
	.dbline 126
	inc R20

⌨️ 快捷键说明

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