单片机开发资料光盘-双龙-686M.zip

源代码在线查看: rtc.s

软件大小: 574027 K
上传用户: rllfllef
关键词: 686 zip 单片机 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module rtc.c
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\RTC\rtc.c
					.dbfunc e time _time fV
					.even
				_time::
					.dbline -1
					.dbline 19
				; /******************************************/
				; /*           广州天河双龙电子公司         */
				; /*           http://www.sl.com.cn         */ 
				; /*              实时时钟演示程序          */
				; /*            作者:ntzwq@wx88.net         */
				; /*               2002年5月12日            */
				; /*  目标MCU:MEGA8   晶振:内部RC(INT) 8MHZ */
				; /******************************************/
				; //说明:ATMEGA8只有在使用内部RC振荡器,T2使用异步时钟的
				; //      情况下,外接的32.768KHZ的晶振才起作用。
				; #include
				; #include
				; #include"uart.h"
				; unsigned char hour;
				; unsigned char minute;
				; unsigned char second;
				; /* 			调整时间 			 */
				; void time(void)
				; 	 {
					.dbline 20
				; 	  if (second					lds R24,_second
					cpi R24,60
					brsh L2
					.dbline 21
				; 	  	  return;
					rjmp L1
				L2:
					.dbline 23
				; 	  else
				; 	    {
					.dbline 24
				; 		 second-=60;
					lds R24,_second
					subi R24,60
					sts _second,R24
					.dbline 25
				; 		 if (minute					lds R24,_minute
					cpi R24,59
					brsh L4
					.dbline 26
				; 		    minute++;
					subi R24,255    ; addi 1
					sts _minute,R24
					rjmp L5
				L4:
					.dbline 28
				; 		 else
				; 		   {
					.dbline 29
				; 		    minute=0;
					clr R2
					sts _minute,R2
					.dbline 30
				; 			if (hour					lds R24,_hour
					cpi R24,23
					brsh L6
					.dbline 31
				; 			   hour++;
					subi R24,255    ; addi 1
					sts _hour,R24
					rjmp L7
				L6:
					.dbline 33
				; 			else
				; 			   hour=0;   
					clr R2
					sts _hour,R2
				L7:
					.dbline 34
				; 		   }	
				L5:
					.dbline 35
				; 		} 		 	  
					.dbline -2
					.dbline 36
				; 	 }
				L1:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e timer2_init _timer2_init fV
					.even
				_timer2_init::
					.dbline -1
					.dbline 39
				; //初始化
				; void timer2_init(void)
				; {
					.dbline 40
				;  TCCR2 = 0x00;
					clr R2
					out 0x25,R2
					.dbline 41
				;  ASSR  = 1					ldi R24,8
					out 0x22,R24
					.dbline 42
				;  TCNT2 = 0xE0; //定时时间1秒
					ldi R24,224
					out 0x24,R24
					.dbline 43
				;  TCCR2 = (1					ldi R24,7
					out 0x25,R24
					.dbline -2
					.dbline 44
				; }
				L8:
					.dbline 0 ; func end
					ret
					.dbend
					.area vector(rom, abs)
					.org 8
					rjmp _timer2_ovf_isr
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\RTC\rtc.c
					.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
					.even
				_timer2_ovf_isr::
					st -y,R24
					st -y,R25
					in R24,0x3f
					st -y,R24
					.dbline -1
					.dbline 47
				; #pragma interrupt_handler timer2_ovf_isr:iv_TIMER2_OVF
				; void timer2_ovf_isr(void)
				; {
					.dbline 48
				;  TCNT2 = 0xE0;
					ldi R24,224
					out 0x24,R24
					.dbline 49
				;  second++;
					lds R24,_second
					subi R24,255    ; addi 1
					sts _second,R24
					.dbline -2
					.dbline 50
				; }
				L9:
					ld R24,y+
					out 0x3f,R24
					ld R25,y+
					ld R24,y+
					.dbline 0 ; func end
					reti
					.dbend
					.dbfunc e put_time _put_time fV
					.even
				_put_time::
					.dbline -1
					.dbline 52
				; void put_time(void)
				;  {
					.dbline 53
				;   putchar(hour/10+0x30);
					ldi R17,10
					lds R16,_hour
					rcall div8u
					subi R16,208    ; addi 48
					rcall _putchar
					.dbline 54
				;   putchar(hour%10+0x30);
					ldi R17,10
					lds R16,_hour
					rcall mod8u
					subi R16,208    ; addi 48
					rcall _putchar
					.dbline 55
				;   putchar(':');
					ldi R16,58
					rcall _putchar
					.dbline 56
				;   putchar(minute/10+0x30);
					ldi R17,10
					lds R16,_minute
					rcall div8u
					subi R16,208    ; addi 48
					rcall _putchar
					.dbline 57
				;   putchar(minute%10+0x30);
					ldi R17,10
					lds R16,_minute
					rcall mod8u
					subi R16,208    ; addi 48
					rcall _putchar
					.dbline 58
				;   putchar(':');
					ldi R16,58
					rcall _putchar
					.dbline 59
				;   putchar(second/10+0x30);
					ldi R17,10
					lds R16,_second
					rcall div8u
					subi R16,208    ; addi 48
					rcall _putchar
					.dbline 60
				;   putchar(second%10+0x30);  
					ldi R17,10
					lds R16,_second
					rcall mod8u
					subi R16,208    ; addi 48
					.dbline -2
					.dbline 61
				;  }
				L10:
					.dbline 0 ; func end
					rjmp _putchar
					.dbend
					.area vector(rom, abs)
					.org 22
					rjmp _uart0_rx_isr
					.area text(rom, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\RTC\rtc.c
					.dbfunc e uart0_rx_isr _uart0_rx_isr fV
				;              i -> R20,R21
					.even
				_uart0_rx_isr::
					rcall push_lset
					rcall push_gset1
					.dbline -1
					.dbline 65
					.dbline 67
					in R20,0xc
					clr R21
					.dbline 68
					cpi R20,116
					ldi R30,0
					cpc R21,R30
					brne L12
					.dbline 69
					.dbline 70
					rcall _getchar
					ldi R24,10
					mul R24,R16
					mov R24,R0
					subi R24,224
					sts _hour,R24
					.dbline 71
					rcall _getchar
					mov R24,R16
					subi R24,48
					lds R2,_hour
					add R2,R24
					sts _hour,R2
					.dbline 72
					rcall _getchar
					ldi R24,10
					mul R24,R16
					mov R24,R0
					subi R24,224
					sts _minute,R24
					.dbline 73
					rcall _getchar
					mov R24,R16
					subi R24,48
					lds R2,_minute
					add R2,R24
					sts _minute,R2
					.dbline 74
					rcall _getchar
					ldi R24,10
					mul R24,R16
					mov R24,R0
					subi R24,224
					sts _second,R24
					.dbline 75
					rcall _getchar
					mov R24,R16
					subi R24,48
					lds R2,_second
					add R2,R24
					sts _second,R2
					.dbline 76
				L12:
					.dbline -2
					.dbline 77
				; //UART接收中断 
				; #pragma interrupt_handler uart0_rx_isr:iv_USART_RXC
				; void uart0_rx_isr(void)
				; {
				;  unsigned i;
				;  i=UDR;
				;  if (i=='t')
				;    {
				;     hour=(getchar()-0x30)*10;
				; 	hour=hour+(getchar()-0x30);
				; 	minute=(getchar()-0x30)*10;
				; 	minute=minute+(getchar()-0x30);
				; 	second=(getchar()-0x30)*10;
				; 	second=second+(getchar()-0x30);
				;    }
				; } 
				L11:
					rcall pop_gset1
					rcall pop_lset
					.dbline 0 ; func end
					reti
					.dbsym r i 20 i
					.dbend
					.dbfunc e main _main fV
				;     second_old -> R20
					.even
				_main::
					.dbline -1
					.dbline 80
				; //main程序
				; void main(void)
				; {
					.dbline 82
				;  unsigned char second_old;
				;  uart_init(); 
					rcall _uart_init
					.dbline 83
				;  timer2_init();
					rcall _timer2_init
					.dbline 84
				;  TIMSK =1					ldi R24,64
					out 0x39,R24
					.dbline 85
				;  SEI();
					sei
					rjmp L16
				L15:
					.dbline 87
				;  while(1)
				;    {
					.dbline 88
				;     if (second!=second_old)
					lds R2,_second
					cp R2,R20
					breq L18
					.dbline 89
				;         {
					.dbline 90
				; 		 time();
					rcall _time
					.dbline 91
				; 		 second_old=second;
					lds R20,_second
					.dbline 92
				; 		 put_time();
					rcall _put_time
					.dbline 93
				; 		}
				L18:
					.dbline 94
				L16:
					.dbline 86
					rjmp L15
				X0:
					.dbline -2
					.dbline 95
				;    }	
				; }
				L14:
					.dbline 0 ; func end
					ret
					.dbsym r second_old 20 c
					.dbend
					.area bss(ram, con, rel)
					.dbfile E:\icc\iccavr\mega8\mega8\RTC\rtc.c
				_second::
					.blkb 1
					.dbsym e second _second c
				_minute::
					.blkb 1
					.dbsym e minute _minute c
				_hour::
					.blkb 1
					.dbsym e hour _hour c
							

相关资源