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

📄 1602.s

📁 1602LCD_mega16.rar
💻 S
📖 第 1 页 / 共 2 页
字号:
; void Delay400Ms(void)
; {
	.dbline 196
;  unsigned char TempCycA = 9;
	ldi R16,9
	xjmp L26
L25:
	.dbline 199
;  unsigned int TempCycB;
;  while(TempCycA--)
;  {
	.dbline 200
;   TempCycB=7777;
	ldi R18,7777
	ldi R19,30
L28:
	.dbline 201
;   while(TempCycB--);
L29:
	.dbline 201
	movw R2,R18
	subi R18,1
	sbci R19,0
	tst R2
	brne L28
	tst R3
	brne L28
X6:
	.dbline 202
;  };
L26:
	.dbline 198
	mov R2,R16
	clr R3
	subi R16,1
	tst R2
	brne L25
X7:
	.dbline 202
	.dbline -2
L24:
	.dbline 0 ; func end
	ret
	.dbsym r TempCycA 16 c
	.dbsym r TempCycB 18 i
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
_dispbuf::
	.blkb 2
	.area idata
	.byte 48,49
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.blkb 2
	.area idata
	.byte 50,51
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.blkb 2
	.area idata
	.byte 52,53
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.blkb 2
	.area idata
	.byte 54,55
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.blkb 2
	.area idata
	.byte 56,57
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.dbsym e dispbuf _dispbuf A[10:10]c
_dispbitcnt::
	.blkb 1
	.area idata
	.byte 8
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.dbsym e dispbitcnt _dispbitcnt c
_mstcnt::
	.blkb 1
	.area idata
	.byte 8
	.area data(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.dbsym e mstcnt _mstcnt c
	.area text(rom, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 218
; }
; 
; /************************************************************************/
; 
; unsigned char dispbuf[]={'0','1','2','3','4','5','6','7','8','9'};
; unsigned char dispbitcnt=8;
; 
; unsigned char second;
; unsigned char minite;
; unsigned char hour;
; unsigned int tcnt;
; unsigned char mstcnt=8,i;
; 
; 
; void port_init(void)
; {
	.dbline 219
;  PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 220
;  DDRA  = 0xFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 221
;  PORTB = 0x00;
	out 0x18,R2
	.dbline 222
;  DDRB  = 0xFF;
	out 0x17,R24
	.dbline 223
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 224
;  DDRC  = 0xFF;
	out 0x14,R24
	.dbline 225
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 226
;  DDRD  = 0xFF;
	out 0x11,R24
	.dbline -2
L31:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 233
; }
; //TIMER0 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value:  1.000mSec (0.0%)
; void timer0_init(void)
; {
	.dbline 234
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 235
;  TCNT0 = 0x83; //set count
	ldi R24,131
	out 0x32,R24
	.dbline 236
;  OCR0  = 0x7D;  //set compare
	ldi R24,125
	out 0x3c,R24
	.dbline 237
;  TCCR0 = 0x03; //start timer
	ldi R24,3
	out 0x33,R24
	.dbline -2
L32:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.even
_timer0_ovf_isr::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R6
	st -y,R7
	st -y,R8
	st -y,R9
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	st -y,R26
	st -y,R27
	st -y,R30
	st -y,R31
	in R0,0x3f
	st -y,R0
	sbiw R28,1
	.dbline -1
	.dbline 242
; }
; 
; #pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
; void timer0_ovf_isr(void)
; {
	.dbline 250
;  //mstcnt--;
;   //if(mstcnt==0)
;     //{
;     //  mstcnt=8;
; 
;    // }	 
;  //for(i=0;i<8;i++)
;  tcnt++;
	lds R24,_tcnt
	lds R25,_tcnt+1
	adiw R24,1
	sts _tcnt+1,R25
	sts _tcnt,R24
	.dbline 252
; 
;   if(tcnt==1000)
	cpi R24,232
	ldi R30,3
	cpc R25,R30
	breq X13
	xjmp L34
X13:
X8:
	.dbline 253
;     {
	.dbline 254
;       tcnt=0;
	clr R2
	clr R3
	sts _tcnt+1,R3
	sts _tcnt,R2
	.dbline 255
;       second++;
	lds R24,_second
	subi R24,255    ; addi 1
	sts _second,R24
	.dbline 256
;       if(second==60)
	cpi R24,60
	brne L36
X9:
	.dbline 257
;         {
	.dbline 258
;           second=0;
	sts _second,R2
	.dbline 259
;           minite++;
	lds R24,_minite
	subi R24,255    ; addi 1
	sts _minite,R24
	.dbline 260
;           if(minite==60)
	cpi R24,60
	brne L38
X10:
	.dbline 261
;             {
	.dbline 262
;               minite=0;
	sts _minite,R2
	.dbline 263
;               hour++;
	lds R24,_hour
	subi R24,255    ; addi 1
	sts _hour,R24
	.dbline 264
;               if(hour==24)
	cpi R24,24
	brne L40
X11:
	.dbline 265
;                 {
	.dbline 266
;                   hour=0;
	sts _hour,R2
	.dbline 267
;                 }
L40:
	.dbline 268
;             }
L38:
	.dbline 269
;         }
L36:
	.dbline 270
;       table_2[7]=dispbuf[second%10];
	ldi R18,10
	ldi R19,0
	lds R16,_second
	clr R17
	xcall mod16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2+7,R2
	.dbline 271
;       table_2[6]=dispbuf[second/10];
	ldi R18,10
	ldi R19,0
	lds R16,_second
	clr R17
	xcall div16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2+6,R2
	.dbline 272
;       table_2[4]=dispbuf[minite%10];
	ldi R18,10
	ldi R19,0
	lds R16,_minite
	clr R17
	xcall mod16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2+4,R2
	.dbline 273
;       table_2[3]=dispbuf[minite/10];
	ldi R18,10
	ldi R19,0
	lds R16,_minite
	clr R17
	xcall div16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2+3,R2
	.dbline 274
;       table_2[1]=dispbuf[hour%10];
	ldi R18,10
	ldi R19,0
	lds R16,_hour
	clr R17
	xcall mod16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2+1,R2
	.dbline 275
;       table_2[0]=dispbuf[hour/10];
	ldi R18,10
	ldi R19,0
	lds R16,_hour
	clr R17
	xcall div16s
	movw R30,R16
	ldi R24,<_dispbuf
	ldi R25,>_dispbuf
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	sts _table_2,R2
	.dbline 277
; 
;     }
L34:
	.dbline 278
;   DisplayOneChar(i, 1, table_2[i]); //显示单个字符
	lds R3,_i
	ldi R24,<_table_2
	ldi R25,>_table_2
	mov R30,R3
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	std y+0,R2
	ldi R18,1
	mov R16,R3
	xcall _DisplayOneChar
	.dbline 280
;  
;       i++;
	lds R24,_i
	subi R24,255    ; addi 1
	sts _i,R24
	.dbline 281
;       if(i==8)
	cpi R24,8
	brne L47
X12:
	.dbline 282
;         {
	.dbline 283
;           i=0;
	clr R2
	sts _i,R2
	.dbline 284
;         }
L47:
	.dbline 287
; 
; 
;  TCNT0 = 0x83; //reload counter value
	ldi R24,131
	out 0x32,R24
	.dbline -2
L33:
	.dbline 0 ; func end
	adiw R28,1
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 292
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 294
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 295
;  port_init();
	xcall _port_init
	.dbline 296
;  timer0_init();
	xcall _timer0_init
	.dbline 298
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 299
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 300
;  TIMSK = 0x01; //timer interrupt sources
	ldi R24,1
	out 0x39,R24
	.dbline 301
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L49:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;              i -> <dead>
	.even
_main::
	sbiw R28,2
	.dbline -1
	.dbline 309
;  //all peripherals are now initialized
; }
; 
; 
; /*******************************************************************************/
; 
; void main(void)
; {
	.dbline 311
;  unsigned  char i;
;  DDRD=0XFF;//PD设为输出
	ldi R24,255
	out 0x11,R24
	.dbline 312
;  DDRB=0XFF;//PB设为输出
	out 0x17,R24
	.dbline 313
;  Delay400Ms(); //启动等待,等LCM讲入工作状态
	xcall _Delay400Ms
	.dbline 314
;  LCMInit(); //LCM初始化
	xcall _LCMInit
	.dbline 315
;  Delay5Ms(); //延时片刻(可不要)
	xcall _Delay5Ms
	.dbline 317
; 
;  DisplayListChar(0, 0, table_1);
	ldi R24,<_table_1
	ldi R25,>_table_1
	std y+1,R25
	std y+0,R24
	clr R18
	clr R16
	xcall _DisplayListChar
	.dbline 335
;  /*Delay400Ms(); //启动等待,等LCM进入工作状态
;  WriteCommandLCM(0x08,1); //关闭显示
;  WriteCommandLCM(0x01,1); //显示清屏
;  WriteCommandLCM(0x06,1); // 显示光标移动设置
;  WriteCommandLCM(0x0f,1); // 显示开及光标设置,闪
;  for(i=0;i<8;i++)
;  {
;   DisplayOneChar(i, 0, table_1[i]); //显示单个字符
;  }
;  WriteCommandLCM(0x07,1); // 显示光标移动设置
;  
;  for(i=0;i<8;i++)
;  {
;   DisplayOneChar(i, 1, table_2[i]); //显示单个字符
;  }
;  //WriteCommandLCM(0x0c,1); // 显示开及光标设置,不闪
;  //ReadDataLCM();//测试用句无意义*/
;  init_devices();
	xcall _init_devices
L51:
	.dbline 336
;  while(1);
L52:
	.dbline 336
	xjmp L51
X14:
	.dbline -2
L50:
	.dbline 0 ; func end
	adiw R28,2
	ret
	.dbsym l i 3 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\学习工具\单片机程序\1602液晶\1602.c
_i::
	.blkb 1
	.dbsym e i _i c
_tcnt::
	.blkb 2
	.dbsym e tcnt _tcnt i
_hour::
	.blkb 1
	.dbsym e hour _hour c
_minite::
	.blkb 1
	.dbsym e minite _minite c
_second::
	.blkb 1
	.dbsym e second _second c
; }

⌨️ 快捷键说明

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