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

📄 main.s

📁 1602lcd显示频率计 通过了proteus仿真
💻 S
字号:
	.module main.c
	.area text(rom, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.area data(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
_str00::
	.blkb 17
	.area idata
	.byte 32,32,'a,'u,'t,'h,'o,'r,58,'a,'n,'c,'i,'e,'n,'t
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbsym e str00 _str00 A[17:17]c
_str01::
	.blkb 17
	.area idata
	.byte 32,'t,'i,'m,'e,58,50,48,48,56,47,48,56,47,48,57
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbsym e str01 _str01 A[17:17]c
_str1::
	.blkb 17
	.area idata
	.byte 32,'f,'r,'e,'q,'u,'e,'n,'c,'y,32,'m,'e,'t,'e,'r
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbsym e str1 _str1 A[17:17]c
_str2::
	.blkb 17
	.area idata
	.byte 32,32,32,32,'F,58,48,48,48,'H,'Z,32,32,32,32,32
	.byte 0
	.area data(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbsym e str2 _str2 A[17:17]c
	.area text(rom, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 36
; /*---------------------------------------------------------------
; 工程名称:1602液晶演示频率计
; 编译器类型及版本:ICCAVR 6.9
; 设计者:余威明
; 设计日期:2007.08.09
; 
; 芯片类型:ATmega16L
; 时钟频率:4M外部时钟
; 硬件接口说明:MCU  ~  LCD
;               PORTD ~  dataport对应1602的d0~d7
;               PA1  ~  RS
;               PA2  ~  RW
;               PA3  ~  E
; ---------------------------------------------------------------*/
; #include <iom16v.h>
; #include <macros.h>
; #include "lcd1602.h"
; 
; 
; void hextoasc(void);    //十六进制转ASCII码
; void timer1_init(void); //定时器1初始化
; void port_init(void);   //端口初始化
; void init_devices(void);
; 
; //显示的两行字符
; unsigned char str00[]="  author:ancient";   //液晶屏初始显示内容
; unsigned char str01[]=" time:2008/08/09";
; unsigned char str1[]=" frequency meter";
; unsigned char str2[]="    F:000HZ     ";    //频率显示形式
; unsigned int count;                      //外部脉冲计数值
; unsigned char tim0_ovf_count;            //t0溢出次数
; //在LCD上显示两行字符
; 
; 
; void main(void)
; {
	.dbline 37
;  init_devices();    //初始化
	xcall _init_devices
	.dbline 38
;  display_a_string(0,str00);   //开机界面
	ldi R18,<_str00
	ldi R19,>_str00
	clr R16
	xcall _display_a_string
	.dbline 39
;     delay_nms(500);
	ldi R16,500
	ldi R17,1
	xcall _delay_nms
	.dbline 40
;  display_a_string(1,str01);
	ldi R18,<_str01
	ldi R19,>_str01
	ldi R16,1
	xcall _display_a_string
	.dbline 41
;    delay_nms(1000);
	ldi R16,1000
	ldi R17,3
	xcall _delay_nms
	.dbline 42
;  lcd_write_command(0x01,1);//显示清屏
	ldi R18,1
	ldi R16,1
	xcall _lcd_write_command
	.dbline 43
;  delay_nms(200);
	ldi R16,200
	ldi R17,0
	xcall _delay_nms
	.dbline 44
;  display_a_string(0,str1);  //显示“frequncy meter”
	ldi R18,<_str1
	ldi R19,>_str1
	clr R16
	xcall _display_a_string
	.dbline 45
;   delay_nms(200);
	ldi R16,200
	ldi R17,0
	xcall _delay_nms
	xjmp L3
L2:
	.dbline 47
;  while(1)
;  {
	.dbline 48
;   hextoasc();    //十六进制转ASCII码
	xcall _hextoasc
	.dbline 49
;   display_a_string(1,str2);
	ldi R18,<_str2
	ldi R19,>_str2
	ldi R16,1
	xcall _display_a_string
	.dbline 50
;   delay_nms(200);
	ldi R16,200
	ldi R17,0
	xcall _delay_nms
	.dbline 51
;  }
L3:
	.dbline 46
	xjmp L2
X0:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e hextoasc _hextoasc fV
	.even
_hextoasc::
	.dbline -1
	.dbline 55
; }
; //十六进制转ASCII码,为LCD显示作准备
; void hextoasc(void)    
; {
	.dbline 56
;  if(count>=1000)  //检测数值大于1000HZ,溢出
	lds R24,_count
	lds R25,_count+1
	cpi R24,232
	ldi R30,3
	cpc R25,R30
	brlo L6
X1:
	.dbline 57
;  {
	.dbline 58
;   str2[6] ='O';   //显示"OVF"
	ldi R24,79
	sts _str2+6,R24
	.dbline 59
;   str2[7] ='V';
	ldi R24,86
	sts _str2+7,R24
	.dbline 60
;   str2[8] ='F';
	ldi R24,70
	sts _str2+8,R24
	.dbline 62
;   
;   PORTC|=(1<<PC0);//PC0置1,发光管亮
	sbi 0x15,0
	.dbline 64
;   
;  }
	xjmp L7
L6:
	.dbline 66
;  else
;  {
	.dbline 67
;   str2[6]=count/100+0x30;
	ldi R18,100
	ldi R19,0
	lds R16,_count
	lds R17,_count+1
	xcall div16u
	movw R24,R16
	adiw R24,48
	sts _str2+6,R24
	.dbline 68
;   str2[7]=count%100/10+0x30;
	ldi R18,100
	ldi R19,0
	lds R16,_count
	lds R17,_count+1
	xcall mod16u
	ldi R18,10
	ldi R19,0
	xcall div16u
	movw R24,R16
	adiw R24,48
	sts _str2+7,R24
	.dbline 69
;   str2[8]=count%10+0x30;
	ldi R18,10
	ldi R19,0
	lds R16,_count
	lds R17,_count+1
	xcall mod16u
	movw R24,R16
	adiw R24,48
	sts _str2+8,R24
	.dbline 70
;   PORTC&=~(1<<PC0);    //PC0清0,发光管灭
	cbi 0x15,0
	.dbline 71
;   }
L7:
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 75
; } 
;  
;  void port_init(void)
; {
	.dbline 76
;  PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 77
;  DDRA  = 0xFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 78
;  PORTB = 0x01;
	ldi R24,1
	out 0x18,R24
	.dbline 79
;  DDRB  = 0xFE;
	ldi R24,254
	out 0x17,R24
	.dbline 80
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 81
;  DDRC  = 0x01;
	ldi R24,1
	out 0x14,R24
	.dbline 82
;  PORTD = 0xff;
	ldi R24,255
	out 0x12,R24
	.dbline 83
;  DDRD  = 0x00;
	out 0x11,R2
	.dbline 85
;  
;  lcd_data_port=0xff;
	out 0x12,R24
	.dbline 86
;  lcd_data_ddr=0xff;
	out 0x11,R24
	.dbline 87
;  lcd_control_port=0x07;
	ldi R24,7
	out 0x1b,R24
	.dbline 88
;  lcd_control_ddr=0x07;
	out 0x1a,R24
	.dbline -2
L14:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 96
; }
; 
; //TIMER1 initialize - prescale:64
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1Hz
; // actual value:  1.000Hz (0.0%)
; void timer1_init(void)
; {
	.dbline 97
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 98
;  TCNT1H = 0x0B; //setup
	ldi R24,11
	out 0x2d,R24
	.dbline 99
;  TCNT1L = 0xDC;
	ldi R24,220
	out 0x2c,R24
	.dbline 101
; 
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 102
;  TCCR1B = 0x03; //start Timer
	ldi R24,3
	out 0x2e,R24
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 106
; }
; 
; void init_devices(void)
; {
	.dbline 108
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 109
;  port_init();
	xcall _port_init
	.dbline 110
;  timer1_init();
	xcall _timer1_init
	.dbline 111
;  TCCR0=0x06;
	ldi R24,6
	out 0x33,R24
	.dbline 112
;  TCNT0=0x00;
	clr R2
	out 0x32,R2
	.dbline 114
;  
;  count=0x00;
	clr R3
	sts _count+1,R3
	sts _count,R2
	.dbline 115
;  tim0_ovf_count=0x00;
	sts _tim0_ovf_count,R2
	.dbline 116
;  timer1_init();
	xcall _timer1_init
	.dbline 118
;  
;  lcd_init();
	xcall _lcd_init
	.dbline 120
;  
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 121
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 122
;  TIMSK = 0x05; //timer interrupt sources
	ldi R24,5
	out 0x39,R24
	.dbline 123
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L16:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.even
_timer0_ovf_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 128
; }
; 
; #pragma interrupt_handler timer0_ovf_isr:iv_TIM0_OVF
; void timer0_ovf_isr(void)
; {
	.dbline 129
;  TCNT0 = 0x00 /*INVALID SETTING*/; //reload counter value
	clr R2
	out 0x32,R2
	.dbline 130
;  tim0_ovf_count++;
	lds R24,_tim0_ovf_count
	subi R24,255    ; addi 1
	sts _tim0_ovf_count,R24
	.dbline -2
L17:
	.dbline 0 ; func end
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	reti
	.dbend
	.area vector(rom, abs)
	.org 32
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 137
; }
; 
; 
; 
; #pragma interrupt_handler timer1_ovf_isr:iv_TIM1_OVF
; void timer1_ovf_isr(void)
; {
	.dbline 139
;  //TIMER1 has overflowed
;  TCNT1H = 0x0B; //reload counter high value
	ldi R24,11
	out 0x2d,R24
	.dbline 140
;  TCNT1L = 0xDC; //reload counter low value
	ldi R24,220
	out 0x2c,R24
	.dbline 141
;  count=tim0_ovf_count*256+TCNT0;
	lds R18,_tim0_ovf_count
	clr R19
	ldi R16,256
	ldi R17,1
	xcall empy16s
	movw R2,R16
	in R4,0x32
	clr R5
	add R2,R4
	adc R3,R5
	sts _count+1,R3
	sts _count,R2
	.dbline 142
;  tim0_ovf_count=0x00;
	clr R2
	sts _tim0_ovf_count,R2
	.dbline 143
;  TCNT0=0x00;
	out 0x32,R2
	.dbline -2
L18:
	.dbline 0 ; func end
	ld R2,y+
	out 0x3f,R2
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	reti
	.dbend
	.area bss(ram, con, rel)
	.dbfile F:\avr单片机学习\我自编程序\1602lcd\main.c
_tim0_ovf_count::
	.blkb 1
	.dbsym e tim0_ovf_count _tim0_ovf_count c
_count::
	.blkb 2
	.dbsym e count _count i
; }

⌨️ 快捷键说明

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