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

📄 pro.s

📁 数字频率计数字频率计数字频率计数字频率计
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module pro.c
	.area data(ram, con, rel)
_Second::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Second _Second c
_Minute::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Minute _Minute c
_Hour::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Hour _Hour c
_time_buffer::
	.blkb 2
	.area idata
	.byte 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.blkb 2
	.area idata
	.byte 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.blkb 2
	.area idata
	.byte 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.blkb 2
	.area idata
	.byte 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e time_buffer _time_buffer A[8:8]c
_Timer1_Counter_H::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Timer1_Counter_H _Timer1_Counter_H c
_Timer1_Counter_L::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Timer1_Counter_L _Timer1_Counter_L c
_value::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e value _value l
_Freq::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Freq _Freq L
_Freq_H16::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Freq_H16 _Freq_H16 L
_Freq_L8::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e Freq_L8 _Freq_L8 L
_counter::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e counter _counter L
_T1_OV_Times::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e T1_OV_Times _T1_OV_Times c
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbfunc e time _time fV
	.even
_time::
	.dbline -1
	.dbline 21
; //包含所需头文件
; #include <ioM16v.h>
; #include <macros.h>
; #include "12864.h"
; #include "delay.h"
; /*------宏定义------*/
; #define uchar	unsigned char
; #define uint	unsigned int
; 
; uchar Second=0,Minute=0,Hour=0;
; uchar Second_H,Second_L,Minute_H,Minute_L,Hour_H,Hour_L;
; uchar time_buffer[8]={0,0,0,0,0,0,0,0};
; unsigned char Timer1_Counter_H=0;
; unsigned char Timer1_Counter_L=0;
; unsigned long value=0;
; long Freq=0,Freq_H16=0,Freq_L8=0,counter=0;
; uchar T1_OV_Times=0; //T1溢出次数
; uchar temp[8];
; 
; void time(void)
; {
	.dbline 22
;  Second++;
	lds R24,_Second
	subi R24,255    ; addi 1
	sts _Second,R24
	.dbline 23
;  if(Second >= 60)
	cpi R24,60
	brlo L2
	.dbline 24
;  {
	.dbline 25
;    Second=0;
	clr R2
	sts _Second,R2
	.dbline 26
;    Minute++;
	lds R24,_Minute
	subi R24,255    ; addi 1
	sts _Minute,R24
	.dbline 27
;    if(Minute >=60)
	cpi R24,60
	brlo L4
	.dbline 28
;    {
	.dbline 29
; 	  Hour++;
	lds R24,_Hour
	subi R24,255    ; addi 1
	sts _Hour,R24
	.dbline 30
; 	  if(Hour >=24)
	cpi R24,24
	brlo L6
	.dbline 31
; 	   Hour=0;
	sts _Hour,R2
L6:
	.dbline 32
; 	}
L4:
	.dbline 33
L2:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e display_time _display_time fV
	.even
_display_time::
	.dbline -1
	.dbline 37
;  }
; }
; 
; void display_time(void)
; {
	.dbline 38
;   time_buffer[0]=Hour/10+0x30;
	ldi R17,10
	lds R16,_Hour
	xcall div8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer,R24
	.dbline 39
;   time_buffer[1]=Hour%10+0x30;
	ldi R17,10
	lds R16,_Hour
	xcall mod8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer+1,R24
	.dbline 40
;   time_buffer[2]=':';
	ldi R24,58
	sts _time_buffer+2,R24
	.dbline 41
;   time_buffer[3]=Minute/10+0x30;
	ldi R17,10
	lds R16,_Minute
	xcall div8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer+3,R24
	.dbline 42
;   time_buffer[4]=Minute%10+0x30;
	ldi R17,10
	lds R16,_Minute
	xcall mod8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer+4,R24
	.dbline 43
;   time_buffer[5]=':';
	ldi R24,58
	sts _time_buffer+5,R24
	.dbline 44
;   time_buffer[6]=Second/10+0x30;
	ldi R17,10
	lds R16,_Second
	xcall div8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer+6,R24
	.dbline 45
;   time_buffer[7]=Second%10+0X30;
	ldi R17,10
	lds R16,_Second
	xcall mod8u
	mov R24,R16
	subi R24,208    ; addi 48
	sts _time_buffer+7,R24
	.dbline 47
;  
;   LCD12864_gotoXY(2,2);
	ldi R18,2
	ldi R16,2
	xcall _LCD12864_gotoXY
	.dbline 48
;   LCD12864_sendstr(time_buffer);
	ldi R16,<_time_buffer
	ldi R17,>_time_buffer
	xcall _LCD12864_sendstr
	.dbline -2
L8:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 62
;   /*LCD12864_sendbyte(1,Hour_H);
;   LCD12864_sendbyte(1,Hour_L);
;   LCD12864_sendbyte(1,':');
;   
;   LCD12864_sendbyte(1,Minute_H);
;   LCD12864_sendbyte(1,Minute_L);
;   LCD12864_sendbyte(1,':');
; 
;   LCD12864_sendbyte(1,Second_H);
;   LCD12864_sendbyte(1,Second_L);*/
; }
; //端口初始化
; void port_init(void)
; {
	.dbline 63
;  PORTA = 0xFF;
	ldi R24,255
	out 0x1b,R24
	.dbline 64
;  DDRA  = 0xFF;
	out 0x1a,R24
	.dbline 65
;  PORTB = 0xf3;
	ldi R24,243
	out 0x18,R24
	.dbline 66
;  DDRB  = 0xf1;
	ldi R24,241
	out 0x17,R24
	.dbline 67
;  PORTC = 0x00;
	clr R2
	out 0x15,R2
	.dbline 68
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 69
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 70
;  DDRD  = 0x00;
	out 0x11,R2
	.dbline -2
L16:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 75
; }
; 
; //定时器T0初始化
; void timer0_init(void)
; {
	.dbline 76
;  TCCR0  = 0x00;//停止定时器
	clr R2
	out 0x33,R2
	.dbline 77
;  TCNT0  = 0x83;//初始值
	ldi R24,131
	out 0x32,R24
	.dbline 78
;  OCR0   = 0x82;//匹配值
	ldi R24,130
	out 0x3c,R24
	.dbline 79
;  TIMSK |= 0x02;//中断允许
	in R24,0x39
	ori R24,2
	out 0x39,R24
	.dbline 80
;  TCCR0  = 0x04;//启动定时器
	ldi R24,4
	out 0x33,R24
	.dbline -2
L17:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
_display_is_ok::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e display_is_ok _display_is_ok c
_count::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e count _count c
	.area vector(rom, abs)
	.org 76
	jmp _timer0_comp_isr
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbfunc e timer0_comp_isr _timer0_comp_isr fV
	.even
_timer0_comp_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 88
	.dbline 90
	lds R24,_count
	subi R24,255    ; addi 1
	mov R2,R24
	sts _count,R2
	cpi R24,5
	brlo L19
	.dbline 91
	.dbline 92
	ldi R24,1
	sts _display_is_ok,R24
	.dbline 93
	clr R2
	sts _count,R2
	.dbline 94
L19:
	.dbline -2
L18:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 99
; }
; 
; uchar display_is_ok=0;
; uchar count=0;
; //T0比较中断服务程序
; #pragma interrupt_handler timer0_comp_isr:20
; void timer0_comp_isr(void)
; {
;  //中断发生时刻在TCNT0=OCR0]
;  if(++count >=5)
;   {
;    display_is_ok=1;
;    count=0;
;    }
; }
; 
; //定时T1初始化
; void timer1_init(void)
; {
	.dbline 100
;  TCCR1B = 0x00;//停止定时器
	clr R2
	out 0x2e,R2
	.dbline 101
;  TIMSK |= 0x04;//中断允许
	in R24,0x39
	ori R24,4
	out 0x39,R24
	.dbline 102
;  TCNT1H = 0x00;
	out 0x2d,R2
	.dbline 103
;  TCNT1L = 0x00;//初始值
	out 0x2c,R2
	.dbline 104
;  OCR1AH = 0xFF;
	ldi R24,255
	out 0x2b,R24
	.dbline 105
;  OCR1AL = 0xFF;//匹配A值
	out 0x2a,R24
	.dbline 106
;  OCR1BH = 0xFF;
	out 0x29,R24
	.dbline 107
;  OCR1BL = 0xFF;//匹配B值
	out 0x28,R24
	.dbline 108
;  ICR1H  = 0xFF;
	out 0x27,R24
	.dbline 109
;  ICR1L  = 0xFF;//输入捕捉匹配值
	out 0x26,R24
	.dbline 110
;  TCCR1A = 0x0C;
	ldi R24,12
	out 0x2f,R24
	.dbline 111
;  TCCR1B = 0x06;//启动定时器
	ldi R24,6
	out 0x2e,R24
	.dbline -2
L21:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 32
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R24
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 118
; }
; 
; 
; //定时器T1溢出中断服务程序
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
	.dbline 121
; // TCNT1H = 0x00; //重装值高位
; // TCNT1L = 0x00; //重装值低位
;  T1_OV_Times=1;
	ldi R24,1
	sts _T1_OV_Times,R24
	.dbline -2
L22:
	ld R24,y+
	out 0x3f,R24
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e timer2_init _timer2_init fV
	.even
_timer2_init::
	.dbline -1
	.dbline 126
; }
; 
; //定时器T2初始化
; void timer2_init(void)
; {
	.dbline 127
;  TCCR2  = 0x00;//停止定时器
	clr R2
	out 0x25,R2
	.dbline 128
;  ASSR   = 0x08;//异步时钟模式
	ldi R24,8
	out 0x22,R24
	.dbline 129
;  TCNT2  = 0x80;//初始值
	ldi R24,128
	out 0x24,R24
	.dbline 130
;  OCR2   = 0x7F;//匹配值
	ldi R24,127
	out 0x23,R24
	.dbline 131
;  TIMSK |= 0x40;//中断允许
	in R24,0x39
	ori R24,64
	out 0x39,R24
	.dbline 132
;  TCCR2  = 0x06;//启动定时器
	ldi R24,6
	out 0x25,R24
	.dbline -2
L23:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
_second_is_ok::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbsym e second_is_ok _second_is_ok c
	.area vector(rom, abs)
	.org 16
	jmp _timer2_ovf_isr
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数字频率计\pro.c
	.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
	.even
_timer2_ovf_isr::
	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
	in R2,0x3f
	st -y,R2
	xcall push_gset2
	.dbline -1
	.dbline 140
; }
; 
; uchar second_is_ok=0;
; //T2溢出中断服务程序
; 
; #pragma interrupt_handler timer2_ovf_isr:5
; void timer2_ovf_isr(void)
; {
	.dbline 142
;  
;  TCCR1B = 0x00;//停止定时器
	clr R2
	out 0x2e,R2
	.dbline 143
;  PORTB &=~(1<<PB0);  //关闭闸门
	cbi 0x18,0
	.dbline 144
;  second_is_ok=1;
	ldi R24,1
	sts _second_is_ok,R24
	.dbline 145
;  value=TCNT1L;
	in R2,0x2c
	clr R3
	clr R4
	clr R5
	sts _value+1,R3
	sts _value,R2
	sts _value+2+1,R5
	sts _value+2,R4
	.dbline 146
;  value|=(TCNT1H << 8); //然后读高位
	in R2,0x2d
	clr R3
	mov R3,R2
	clr R2
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	lds R8,_value+2
	lds R9,_value+2+1
	lds R6,_value
	lds R7,_value+1
	or R6,R2
	or R7,R3
	or R8,R4
	or R9,R5
	sts _value+1,R7
	sts _value,R6
	sts _value+2+1,R9
	sts _value+2,R8
	.dbline 148
;   //读取计数值
; Freq_H16=value;
	movw R2,R6
	movw R4,R8
	sts _Freq_H16+1,R3
	sts _Freq_H16,R2
	sts _Freq_H16+2+1,R5
	sts _Freq_H16+2,R4
	.dbline 149
; counter=Freq_H16;
	lds R4,_Freq_H16+2
	lds R5,_Freq_H16+2+1
	lds R2,_Freq_H16
	lds R3,_Freq_H16+1
	sts _counter+1,R3
	sts _counter,R2
	sts _counter+2+1,R5
	sts _counter+2,R4
	.dbline 150
; Freq_H16 =Freq_H16*256;
	ldi R20,0
	ldi R21,1
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32s
	sts _Freq_H16+1,R17
	sts _Freq_H16,R16
	sts _Freq_H16+2+1,R19
	sts _Freq_H16+2,R18
	.dbline 152
; 
; Freq_L8 =(PIND & 0b11111111);    //读取计数值的低8位
	in R24,0x10
	clr R25
	andi R25,0
	movw R2,R24
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	sts _Freq_L8+1,R3
	sts _Freq_L8,R2
	sts _Freq_L8+2+1,R5
	sts _Freq_L8+2,R4
	.dbline 153
; Freq=Freq_H16+Freq_L8;
	movw R6,R16
	movw R8,R18
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	sts _Freq+1,R7
	sts _Freq,R6
	sts _Freq+2+1,R9
	sts _Freq+2,R8
	.dbline 154
;  if(T1_OV_Times !=0)
	lds R2,_T1_OV_Times
	tst R2
	breq L25
	.dbline 155
;  {
	.dbline 156
;    Freq+=(unsigned long)0xffff*0xff*T1_OV_Times;
	clr R3
	clr R4
	clr R5
	ldi R20,1
	ldi R21,255
	ldi R22,254
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	lds R4,_Freq+2
	lds R5,_Freq+2+1
	lds R2,_Freq
	lds R3,_Freq+1
	add R2,R16
	adc R3,R17
	adc R4,R18
	adc R5,R19
	sts _Freq+1,R3
	sts _Freq,R2
	sts _Freq+2+1,R5
	sts _Freq+2,R4
	.dbline 157
;    T1_OV_Times=0;
	clr R2
	sts _T1_OV_Times,R2
	.dbline 158

⌨️ 快捷键说明

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