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

📄 signal.s

📁 简易信号发生器+Protues仿真,函数波形发生器产生波形表
💻 S
字号:
	.module signal.C
	.area text(rom, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
_h::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e h _h c
_j::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e j _j c
_k::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e k _k c
_th1::
	.blkb 1
	.area idata
	.byte 231
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e th1 _th1 c
_tl1::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e tl1 _tl1 c
_f1::
	.blkb 1
	.area idata
	.byte 6
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e f1 _f1 c
_f2::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e f2 _f2 c
_i::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbsym e i _i i
	.area code(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.area lit(rom, con, rel)
_sin_table::
	.byte 128,131
	.byte 134,137
	.byte 140,143
	.byte 146,149
	.byte 152,156
	.byte 159,162
	.byte 165,168
	.byte 171,174
	.byte 176,179
	.byte 182,185
	.byte 188,191
	.byte 193,196
	.byte 199,201
	.byte 204,206
	.byte 209,211
	.byte 213,216
	.byte 218,220
	.byte 222,224
	.byte 226,228
	.byte 230,232
	.byte 234,236
	.byte 237,239
	.byte 240,242
	.byte 243,244
	.byte 246,247
	.byte 248,249
	.byte 250,251
	.byte 252,252
	.byte 253,254
	.byte 254,255
	.byte 255,255
	.byte 255,255
	.byte 255,255
	.byte 255,255
	.byte 255,255
	.byte 254,254
	.byte 253,252
	.byte 252,251
	.byte 250,249
	.byte 248,247
	.byte 246,245
	.byte 243,242
	.byte 240,239
	.byte 237,236
	.byte 234,232
	.byte 230,228
	.byte 227,225
	.byte 222,220
	.byte 218,216
	.byte 214,211
	.byte 209,206
	.byte 204,201
	.byte 199,196
	.byte 193,191
	.byte 188,185
	.byte 182,180
	.byte 177,174
	.byte 171,168
	.byte 165,162
	.byte 159,156
	.byte 153,150
	.byte 146,143
	.byte 140,137
	.byte 134,131
	.byte 128,125
	.byte 'y,'v
	.byte 's,'p
	.byte 'm,'j
	.byte 'g,'d
	.byte 'a,94
	.byte 91,'X
	.byte 'U,'R
	.byte 'O,'L
	.byte 'I,'F
	.byte 'C,'A
	.byte 62,59
	.byte 57,54
	.byte 51,49
	.byte 46,44
	.byte 42,39
	.byte 37,35
	.byte 33,31
	.byte 29,27
	.byte 25,23
	.byte 21,20
	.byte 18,16
	.byte 15,13
	.byte 12,11
	.byte 9,8
	.byte 7,6
	.byte 5,4
	.byte 3,3
	.byte 2,1
	.byte 1,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 0,0
	.byte 1,1
	.byte 2,3
	.byte 3,4
	.byte 5,6
	.byte 7,8
	.byte 9,10
	.byte 12,13
	.byte 14,16
	.byte 18,19
	.byte 21,23
	.byte 24,26
	.byte 28,30
	.byte 32,35
	.byte 37,39
	.byte 41,44
	.byte 46,48
	.byte 51,53
	.byte 56,59
	.byte 61,64
	.byte 'C,'F
	.byte 'H,'K
	.byte 'N,'Q
	.byte 'T,'W
	.byte 'Z,93
	.byte 96,'c
	.byte 'f,'i
	.byte 'l,'o
	.byte 's,'v
	.byte 'y,124
	.dbsym e sin_table _sin_table A[256:256]kc
	.area text(rom, con, rel)
	.dbfile E:\OK\DA0832\signal.C
	.dbfunc e delay _delay fV
;              i -> R20,R21
;              j -> R22,R23
;             ms -> R16,R17
	.even
_delay::
	rcall push_xgsetF000
	.dbline -1
	.dbline 38
; //ICC-AVR application builder : 2008-9-7 11:00:08
; // Target : M8515
; // Crystal: 16.000Mhz
; 
; #include <iom8515v.h>
; #include <macros.h>
; 
; 
; #define uchar unsigned char
; #define uint  unsigned int
; 
; #define data1 PORTB
; 
; uchar h=0,j=0,k=0,func,th1=0xE7,tl1=0;
; uchar f1=0x06,f2=0;    //250Hz的步进
; uint i=0;
; #pragma data:code
; const uchar sin_table[256]=
; {
; 0x80,0x83,0x86,0x89,0x8c,0x8f,0x92,0x95,0x98,0x9c,0x9f,0xa2,0xa5,0xa8,0xab,0xae,
; 0xb0,0xb3,0xb6,0xb9,0xbc,0xbf,0xc1,0xc4,0xc7,0xc9,0xcc,0xce,0xd1,0xd3,0xd5,0xd8,
; 0xda,0xdc,0xde,0xe0,0xe2,0xe4,0xe6,0xe8,0xea,0xec,0xed,0xef,0xf0,0xf2,0xf3,0xf4,
; 0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfc,0xfd,0xfe,0xfe,0xff,0xff,0xff,0xff,0xff,
; 0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xfd,0xfc,0xfc,0xfb,0xfa,0xf9,0xf8,0xf7,
; 0xf6,0xf5,0xf3,0xf2,0xf0,0xef,0xed,0xec,0xea,0xe8,0xe6,0xe4,0xe3,0xe1,0xde,0xdc,
; 0xda,0xd8,0xd6,0xd3,0xd1,0xce,0xcc,0xc9,0xc7,0xc4,0xc1,0xbf,0xbc,0xb9,0xb6,0xb4,
; 0xb1,0xae,0xab,0xa8,0xa5,0xa2,0x9f,0x9c,0x99,0x96,0x92,0x8f,0x8c,0x89,0x86,0x83,
; 0x80,0x7d,0x79,0x76,0x73,0x70,0x6d,0x6a,0x67,0x64,0x61,0x5e,0x5b,0x58,0x55,0x52,
; 0x4f,0x4c,0x49,0x46,0x43,0x41,0x3e,0x3b,0x39,0x36,0x33,0x31,0x2e,0x2c,0x2a,0x27,
; 0x25,0x23,0x21,0x1f,0x1d,0x1b,0x19,0x17,0x15,0x14,0x12,0x10,0xf,0xd,0xc,0xb,0x9,
; 0x8,0x7,0x6,0x5,0x4,0x3,0x3,0x2,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
; 0x0,0x1,0x1,0x2,0x3,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xc,0xd,0xe,0x10,0x12,0x13,
; 0x15,0x17,0x18,0x1a,0x1c,0x1e,0x20,0x23,0x25,0x27,0x29,0x2c,0x2e,0x30,0x33,0x35,
; 0x38,0x3b,0x3d,0x40,0x43,0x46,0x48,0x4b,0x4e,0x51,0x54,0x57,0x5a,0x5d,0x60,0x63,
; 0x66,0x69,0x6c,0x6f,0x73,0x76,0x79,0x7c
; };
; void delay(uint ms)
; {
	.dbline 40
;         uint i,j;
; 	for(i=0;i<ms;i++)
	clr R20
	clr R21
	rjmp L5
L2:
	.dbline 41
; 	   {
	.dbline 42
; 	   for(j=0;j<1141;j++);
	clr R22
	clr R23
	rjmp L9
L6:
	.dbline 42
L7:
	.dbline 42
	subi R22,255  ; offset = 1
	sbci R23,255
L9:
	.dbline 42
	cpi R22,117
	ldi R30,4
	cpc R23,R30
	brlo L6
X0:
	.dbline 43
;        }
L3:
	.dbline 40
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	.dbline 40
	cp R20,R16
	cpc R21,R17
	brlo L2
X1:
	.dbline -2
L1:
	.dbline 0 ; func end
	rjmp pop_xgsetF000
	.dbsym r i 20 i
	.dbsym r j 22 i
	.dbsym r ms 16 i
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 47
; }
; 
; void port_init(void)
; {
	.dbline 48
;  PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 49
;  DDRB  = 0xff;
	ldi R24,255
	out 0x17,R24
	.dbline 50
;  PORTC = 0x00;
	out 0x15,R2
	.dbline 51
;  DDRC  = 0xff;
	out 0x14,R24
	.dbline 52
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 53
;  DDRD  = 0x01; 
	ldi R24,1
	out 0x11,R24
	.dbline 54
;  PORTE = 0x00;
	out 0x7,R2
	.dbline 55
;  DDRE  = 0x00; 
	out 0x6,R2
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 63
; }
; 
; //TIMER1 initialize - prescale:1
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 400uSec
; // actual value: 400.000uSec (0.0%)
; void timer1_init(void)
; {
	.dbline 64
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 65
;  TCNT1H = th1; //setup       //th1,tl1用来改变频率
	lds R2,_th1
	out 0x2d,R2
	.dbline 66
;  TCNT1L = tl1;
	lds R2,_tl1
	out 0x2c,R2
	.dbline 67
;  OCR1AH = 0x20;
	ldi R24,32
	out 0x2b,R24
	.dbline 68
;  OCR1AL = 0x00;
	clr R2
	out 0x2a,R2
	.dbline 69
;  OCR1BH = 0x20;
	out 0x29,R24
	.dbline 70
;  OCR1BL = 0x00;
	out 0x28,R2
	.dbline 71
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 72
;  TCCR1B = 0x01; //start Timer
	ldi R24,1
	out 0x2e,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 12
	rjmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile E:\OK\DA0832\signal.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,R24
	st -y,R25
	st -y,R30
	st -y,R31
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 76
; }
; #pragma interrupt_handler timer1_ovf_isr:iv_TIM1_OVF
; void timer1_ovf_isr(void)
; {
	.dbline 77
;   TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 78
;   TCNT1H = th1; //reload counter high value
	lds R2,_th1
	out 0x2d,R2
	.dbline 79
;   TCNT1L = tl1; //reload counter low value
	lds R2,_tl1
	out 0x2c,R2
	.dbline 81
;   //func=1;             //设置调试点,计算时间
;   if(func==1)         //正弦波
	lds R24,_func
	cpi R24,1
	brne L13
X2:
	.dbline 82
;    {
	.dbline 83
;      data1=sin_table[j++];
	lds R2,_j
	clr R3
	mov R24,R2
	subi R24,255    ; addi 1
	sts _j,R24
	ldi R24,<_sin_table
	ldi R25,>_sin_table
	mov R30,R2
	clr R31
	add R30,R24
	adc R31,R25
	lpm R2,Z
	out 0x18,R2
	.dbline 84
;    }    
L13:
	.dbline 86
;      //func++;             //设置调试点
;     if(func==2)    // 锯齿波
	lds R24,_func
	cpi R24,2
	brne L15
X3:
	.dbline 87
;    {
	.dbline 88
;      if(h<128)
	lds R24,_h
	cpi R24,128
	brsh L17
X4:
	.dbline 89
; 	   data1=h;
	out 0x18,R24
	rjmp L18
L17:
	.dbline 91
; 	 else
; 	   data1=255-h;
	lds R2,_h
	clr R3
	ldi R24,255
	ldi R25,0
	movw R4,R24
	sub R4,R2
	sbc R5,R3
	out 0x18,R4
L18:
	.dbline 92
; 	   h++;
	lds R24,_h
	subi R24,255    ; addi 1
	sts _h,R24
	.dbline 93
;    }
	rjmp L16
L15:
	.dbline 94
;    else if(func==3)     // 方波
	lds R24,_func
	cpi R24,3
	brne L19
X5:
	.dbline 95
;    { 
	.dbline 96
;       k++;
	lds R24,_k
	subi R24,255    ; addi 1
	sts _k,R24
	.dbline 97
; 	  if(k<=127)
	ldi R24,127
	lds R2,_k
	cp R24,R2
	brlo L21
X6:
	.dbline 98
; 	    data1=0x00;
	clr R2
	out 0x18,R2
	rjmp L22
L21:
	.dbline 100
; 	  else
; 	    data1=0xff;
	ldi R24,255
	out 0x18,R24
L22:
	.dbline 102
;    
;    }
L19:
L16:
	.dbline 104
;   
;   TCCR1B = 0x01; //start Timer
	ldi R24,1
	out 0x2e,R24
	.dbline -2
L12:
	.dbline 0 ; func end
	ld R2,y+
	out 0x3f,R2
	ld R31,y+
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 110
; } 
; 
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 112
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 113
;  port_init();
	rcall _port_init
	.dbline 114
;  timer1_init();
	rcall _timer1_init
	.dbline 116
; 
;  MCUCR = 0x02;
	ldi R24,2
	out 0x35,R24
	.dbline 117
;  EMCUCR = 0x00;
	clr R2
	out 0x36,R2
	.dbline 118
;  GICR = 0x40;
	ldi R24,64
	out 0x3b,R24
	.dbline 119
;  TIMSK = 0x80;
	ldi R24,128
	out 0x39,R24
	.dbline 120
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L23:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e key_read _key_read fV
;            num -> <dead>
;              i -> R16
	.even
_key_read::
	.dbline -1
	.dbline 125
;  //all peripherals are now initialized
; }
; 
; void key_read()
; {
	.dbline 127
;   uchar num,i;
;   DDRA=0xff;     // 都定义为输出
	ldi R24,255
	out 0x1a,R24
	.dbline 128
;   PORTA=0xf0;   // 高位输出高电平,低位输出低电平
	ldi R24,240
	out 0x1b,R24
	.dbline 129
;   DDRA=0x0f;  // 有键按下,把相应列(高位)的电平拉低
	ldi R24,15
	out 0x1a,R24
	.dbline 130
;   asm("nop");
	nop
	.dbline 131
;   i=PINA;    //获取列的地址,即
	in R16,0x19
	.dbline 132
;   DDRA=0xff;
	ldi R24,255
	out 0x1a,R24
	.dbline 133
;   PORTA=0x0f;
	ldi R24,15
	out 0x1b,R24
	.dbline 134
;   DDRA=0xf0;  //把相应行的电平拉低
	ldi R24,240
	out 0x1a,R24
	.dbline 135
;   asm("nop");
	nop
	.dbline 136
;   i|=PINA;     //获取行的地址 ,行与列的地址决定按键的位置
	in R2,0x19
	or R16,R2
	.dbline 137
;   switch(i)
	clr R17
	cpi R16,187
	ldi R30,0
	cpc R17,R30
	brne X22
	rjmp L26
X22:
X7:
	cpi R16,189
	ldi R30,0
	cpc R17,R30
	brne X23
	rjmp L26
X23:
X8:
	ldi R24,189
	ldi R25,0
	cp R24,R16
	cpc R25,R17
	brlt L41
X9:
L40:
	cpi R16,123
	ldi R30,0
	cpc R17,R30
	brne X24
	rjmp L31
X24:
X10:
	cpi R16,125
	ldi R30,0
	cpc R17,R30
	brne X25
	rjmp L32
X25:
X11:
	ldi R24,125
	ldi R25,0
	cp R24,R16
	cpc R25,R17
	brlt L43
X12:
L42:
	cpi R16,119
	ldi R30,0
	cpc R17,R30
	breq L28
X13:
	rjmp L26
L43:
	cpi R16,183
	ldi R30,0
	cpc R17,R30
	brne X26
	rjmp L26
X26:
X14:
	rjmp L26
L41:
	cpi R16,219
	ldi R30,0
	cpc R17,R30
	brne X27
	rjmp L26
X27:
X15:
	ldi R24,219
	ldi R25,0
	cp R24,R16
	cpc R25,R17
	brlt L45
X16:
L44:
	cpi R16,215
	ldi R30,0
	cpc R17,R30
	breq L26
X17:
	rjmp L26
L45:
	cpi R16,231
	ldi R30,0
	cpc R17,R30
	breq L26
X18:
	cpi R16,231
	ldi R30,0
	cpc R17,R30
	brlt L26
X19:
L46:
	cpi R16,235
	ldi R30,0
	cpc R17,R30
	breq L26
X20:
	rjmp L26
L28:
	.dbline 140
;   {
; 	case 0x77 : 
; 	{
	.dbline 141
; 	  func++; 
	lds R24,_func
	subi R24,255    ; addi 1
	sts _func,R24
	.dbline 142
; 	  if(func==4) 
	cpi R24,4
	brne L26
X21:
	.dbline 143
; 	  func=0x00;  break;
	clr R2
	sts _func,R2
	.dbline 143
	rjmp L26
L31:
	.dbline 146
; 	}	
; 	case 0x7B :       //频率加250Hz
;     {
	.dbline 147
;       th1-=f1;
	lds R2,_f1
	lds R3,_th1
	sub R3,R2
	sts _th1,R3
	.dbline 148
; 	  tl1-=f2;
	lds R2,_f2
	lds R3,_tl1
	sub R3,R2
	sts _tl1,R3
	.dbline 149
; 	  break;
	rjmp L26
L32:
	.dbline 152
;     } 
; 	case 0x7D :      ////频率减250Hz
; 	 {
	.dbline 153
; 	   th1+=f1;
	lds R2,_f1
	lds R3,_th1
	add R3,R2
	sts _th1,R3
	.dbline 154
; 	   tl1+=f2;
	lds R2,_f2
	lds R3,_tl1
	add R3,R2
	sts _tl1,R3
	.dbline 155
; 	   break;
	.dbline 193
; 	 }
; 	/*case 0xEE : 
; 	{
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00;  break;
; 	}
; 	case 0xDE : 
; 	{
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00; break;
; 	}
; 	case 0xBE : 
;     {
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00; break;
; 	}
; 	case 0x7E : 
;     {
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00; break;
; 	}
; 	case 0xED : 
; 	{
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00; break;
; 	}	
; 	case 0xDD : 
; 	{
; 	  func++; 
; 	  if(func==4) 
; 	  func=0x00; break;
; 	}	*/
; 	case 0xBD : ; break;
	.dbline 193
	.dbline 194
; 	case 0xEB : ; break;
	.dbline 194
	.dbline 195
; 	case 0xDB : ; break;
	.dbline 195
	.dbline 196
; 	case 0xBB : ; break;
	.dbline 196
	.dbline 197
; 	case 0xE7 : ; break;
	.dbline 197
	.dbline 198
; 	case 0xD7 : ; break;
	.dbline 198
	.dbline 199
; 	case 0xB7 : ; break;
	.dbline 199
	.dbline 202
; 
; 	
; 	default : break;
L26:
	.dbline -2
L24:
	.dbline 0 ; func end
	ret
	.dbsym l num 1 c
	.dbsym r i 16 c
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 209
;    }
; 
; }
; 
; 
; void main()
; {
	.dbline 212
;    //set_cw1;
;    //set_xwr2;
;    init_devices();
	rcall _init_devices
	rjmp L49
L48:
	.dbline 214
;    while(1)
;     { 
	.dbline 215
; 	  key_read();
	rcall _key_read
	.dbline 217
; 	  
; 	}
L49:
	.dbline 213
	rjmp L48
X28:
	.dbline -2
L47:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\OK\DA0832\signal.C
_func::
	.blkb 1
	.dbsym e func _func c
; 
; }

⌨️ 快捷键说明

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