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

📄 test.s

📁 针对多路视频远程无线传输问题
💻 S
字号:
	.module test.c
	.area text(rom, con, rel)
	.dbfile D:\工作\video切换\soft\按键切换\test.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 19
; //ICC-AVR application builder : 2006-3-22 10:22:28
; // Target : M8
; // Crystal: 11.059Mhz
; 
; #include <iom8v.h>
; #include <macros.h>
; //#include <stddef.h>
; 
; unsigned char ICP_Flag;
; unsigned int ICP_value_down;
; unsigned char state;
; 
; #define LED1_ON()     PORTD=0x01;PORTC = 0x00;PORTC=0x01;
; #define LED2_ON()     PORTD=0x02;PORTC = 0x00;PORTC=0x02;
; #define LED3_ON()     PORTD=0x04;PORTC = 0x00;PORTC=0x04;
; #define LED4_ON()     PORTD=0x08;PORTC = 0x00;PORTC=0x08;
; 
; void port_init(void)
; {
	.dbline 20
;  PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 21
;  DDRB  = 0x00;
	out 0x17,R2
	.dbline 22
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 23
;  DDRC  = 0x0F;
	ldi R24,15
	out 0x14,R24
	.dbline 24
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 25
;  DDRD  = 0x0F;
	out 0x11,R24
	.dbline -2
	.dbline 26
; }
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 33
; 
; //TIMER1 initialize - prescale:Stop
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1Hz
; // actual value: Out of range
; void timer1_init(void)
; {
	.dbline 34
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 35
;  TCNT1H = 0x00 /*INVALID SETTING*/; //setup
	out 0x2d,R2
	.dbline 36
;  TCNT1L = 0x00 /*INVALID SETTING*/;
	out 0x2c,R2
	.dbline 37
;  OCR1AH = 0x00 /*INVALID SETTING*/;
	out 0x2b,R2
	.dbline 38
;  OCR1AL = 0x00 /*INVALID SETTING*/;
	out 0x2a,R2
	.dbline 39
;  OCR1BH = 0x00 /*INVALID SETTING*/;
	out 0x29,R2
	.dbline 40
;  OCR1BL = 0x00 /*INVALID SETTING*/;
	out 0x28,R2
	.dbline 41
;  ICR1H  = 0x00 /*INVALID SETTING*/;
	out 0x27,R2
	.dbline 42
;  ICR1L  = 0x00 /*INVALID SETTING*/;
	out 0x26,R2
	.dbline 43
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 44
;  TCCR1B = 0xC0; //start Timer
	ldi R24,192
	out 0x2e,R24
	.dbline -2
	.dbline 45
; }
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e delay_s _delay_s fV
;              i -> R20,R21
;              j -> R22,R23
;              x -> R16
	.even
_delay_s::
	rcall push_gset2
	.dbline -1
	.dbline 49
; 
; ///////////////////////////////////////延时程序
; void delay_s(char x)   
; {
	rjmp L5
L4:
	.dbline 53
; int i;
; int j;
; while(x--)
; {
	.dbline 54
; for(i=0;i<500;i++)
	clr R20
	clr R21
L7:
	.dbline 55
;   {
	.dbline 56
;   for(j=0;j<1000;j++)
	clr R22
	clr R23
L11:
	.dbline 57
L12:
	.dbline 56
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 56
	cpi R22,232
	ldi R30,3
	cpc R23,R30
	brlt L11
	.dbline 58
L8:
	.dbline 54
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 54
	cpi R20,244
	ldi R30,1
	cpc R21,R30
	brlt L7
	.dbline 59
L5:
	.dbline 52
	mov R2,R16
	clr R3
	subi R16,1
	tst R2
	brne L4
	.dbline -2
	.dbline 60
;   ;
;   }
; }
; }
L3:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 I
	.dbsym r j 22 I
	.dbsym r x 16 c
	.dbend
	.dbfunc e VideoSwitch _VideoSwitch fV
;        Counter -> R20,R21
	.even
_VideoSwitch::
	rcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 64
; //////////////////////////////////////
; 
; void VideoSwitch(unsigned int Counter)	   //根据捕捉计数值切换视频通道
; {
	.dbline 65
;      if(Counter>0x0D7E)
	ldi R24,3454
	ldi R25,13
	cp R24,R20
	cpc R25,R21
	brsh L16
	.dbline 66
; 	    {   //超过2.5ms,可能是漏掉了一个脉宽信号,不做动作
	.dbline 68
; 			//LED1_ON(); 										  
; 		    return;
	rjmp L15
L16:
	.dbline 71
; 		}
; 	 
;  	 if(Counter<0x0818)//状态1:			   0.5~1.5ms
	cpi R20,24
	ldi R30,8
	cpc R21,R30
	brsh L18
	.dbline 72
; 	 	{
	.dbline 74
; 		 	//LED2_ON(); 
; 		}
	rjmp L19
L18:
	.dbline 76
; 		else
; 		{ //1.5ms~2.5ms
	.dbline 77
; 		  if(state > 1)
	ldi R24,1
	lds R2,_state
	cp R24,R2
	brsh L20
	.dbline 78
; 		     state = 0;
	clr R2
	sts _state,R2
L20:
	.dbline 80
; 
; 		   switch(state)
	lds R20,_state
	clr R21
	cpi R20,0
	cpc R20,R21
	breq L25
X0:
	cpi R20,1
	ldi R30,0
	cpc R21,R30
	breq L26
	rjmp L22
X1:
	.dbline 81
; 		   {
L25:
	.dbline 83
; 		   	   case 0:
; 			       LED2_ON();
	ldi R24,2
	out 0x12,R24
	.dbline 83
	clr R2
	out 0x15,R2
	.dbline 83
	out 0x15,R24
	.dbline 83
	.dbline 84
; 				   break;
	rjmp L23
L26:
	.dbline 86
; 			   case 1:
; 			       LED4_ON();
	ldi R24,8
	out 0x12,R24
	.dbline 86
	clr R2
	out 0x15,R2
	.dbline 86
	out 0x15,R24
	.dbline 86
	.dbline 87
; 				   break;
L22:
L23:
	.dbline 89
	lds R24,_state
	subi R24,255    ; addi 1
	sts _state,R24
	.dbline 90
	ldi R16,4
	rcall _delay_s
	.dbline 91
L19:
	.dbline -2
	.dbline 94
; 		   }
; 		   state++;
; 		   delay_s(4);
;            return;	
; 		  // LED3_ON();   
; 		}
; }
L15:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r Counter 20 i
	.dbend
	.area vector(rom, abs)
	.org 16
	rjmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile D:\工作\video切换\soft\按键切换\test.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R24
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 98
; 
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
	.dbline 100
;  //TIMER1 has overflowed
;  TCNT1H = 0x00 /*INVALID SETTING*/; //reload counter high value
	clr R2
	out 0x2d,R2
	.dbline 101
;  TCNT1L = 0x00 /*INVALID SETTING*/; //reload counter low value
	out 0x2c,R2
	.dbline 102
;  TCCR1B |= 0xc0;  //回到等待上升沿的状态
	in R24,0x2e
	ori R24,192
	out 0x2e,R24
	.dbline -2
	.dbline 103
; }
L27:
	ld R2,y+
	out 0x3f,R2
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 10
	rjmp _timer1_capt_isr
	.area text(rom, con, rel)
	.dbfile D:\工作\video切换\soft\按键切换\test.c
	.dbfunc e timer1_capt_isr _timer1_capt_isr fV
	.even
_timer1_capt_isr::
	rcall push_lset
	rcall push_gset1
	.dbline -1
	.dbline 107
; 
; #pragma interrupt_handler timer1_capt_isr:6
; void timer1_capt_isr(void)
; {
	.dbline 111
;  //timer 1 input capture event, read (int)value in ICR1 using;
;  // value=ICR1L;            //Read low byte first (important)
;  // value|=(int)ICR1H << 8; //Read high byte and shift into top byte
;  	switch(ICP_Flag)//根据状态值判断捕捉到的是什么跳变信号
	lds R20,_ICP_Flag
	clr R21
	cpi R20,0
	cpc R20,R21
	breq L33
X2:
	cpi R20,1
	ldi R30,0
	cpc R21,R30
	breq L32
	rjmp L29
X3:
	.dbline 112
; 	 {
L32:
	.dbline 114
;  	  	case 1://0x40://捕捉到上升沿
; 			 TCNT1H = 0x00; //reload counter high value
	clr R2
	out 0x2d,R2
	.dbline 115
; 			 TCNT1L = 0x00; //reload counter low value
	out 0x2c,R2
	.dbline 116
; 			 TCCR1B &= 0xBF; //ICES1->0,转为捕捉下降沿
	in R24,0x2e
	andi R24,191
	out 0x2e,R24
	.dbline 117
; 			 TCCR1B |= 0x82;	//开捕捉,开启定时器,8分频
	in R24,0x2e
	ori R24,130
	out 0x2e,R24
	.dbline 118
; 			 ICP_Flag = 0;
	sts _ICP_Flag,R2
	.dbline 119
; 			 break;
	rjmp L30
L33:
	.dbline 122
; 		
; 		case 0://0x00://捕捉到下降沿
; 			 TCCR1B &= 0xf8; //关闭定时器
	in R24,0x2e
	andi R24,248
	out 0x2e,R24
	.dbline 123
; 			 ICP_value_down = ICR1L;//Read low byte first (important)
	in R2,0x26
	clr R3
	sts _ICP_value_down+1,R3
	sts _ICP_value_down,R2
	.dbline 124
; 			 ICP_value_down |= (int)ICR1H << 8; //Read high byte and shift into top byte
	in R2,0x27
	clr R3
	mov R3,R2
	clr R2
	lds R4,_ICP_value_down
	lds R5,_ICP_value_down+1
	or R4,R2
	or R5,R3
	sts _ICP_value_down+1,R5
	sts _ICP_value_down,R4
	.dbline 125
; 			 VideoSwitch(ICP_value_down);
	movw R16,R4
	rcall _VideoSwitch
	.dbline 126
; 			 TCCR1B |= 0x40; //ICES1->1完成一个正脉宽捕捉,回到等待上升沿的状态
	in R24,0x2e
	ori R24,64
	out 0x2e,R24
	.dbline 127
; 			 ICP_Flag = 1;
	ldi R24,1
	sts _ICP_Flag,R24
	.dbline 128
; 			 break;
L29:
L30:
	.dbline -2
	.dbline 130
;  	 }
; }
L28:
	rcall pop_gset1
	rcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 134
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 136
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 137
;  port_init();
	rcall _port_init
	.dbline 138
;  timer1_init();
	rcall _timer1_init
	.dbline 140
; 
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 141
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 142
;  TIMSK = 0x24; //timer interrupt sources
	ldi R24,36
	out 0x39,R24
	.dbline 143
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
	.dbline 145
;  //all peripherals are now initialized
; }
L34:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 148
; 
; void main()
; {
	.dbline 149
;  	 init_devices();
	rcall _init_devices
	.dbline 150
; 	 state = 0;
	clr R2
	sts _state,R2
	.dbline 151
; 	 ICP_value_down = 0;
	clr R3
	sts _ICP_value_down+1,R3
	sts _ICP_value_down,R2
	.dbline 152
; 	 PORTD = 0x08;
	ldi R24,8
	out 0x12,R24
	.dbline 153
; 	 PORTC = 0x08;
	out 0x15,R24
L36:
	.dbline 155
	.dbline 156
	.dbline 157
L37:
	.dbline 154
	rjmp L36
X4:
	.dbline -2
	.dbline 158
; 	 while(1)
; 	 {
; 	  ;
; 	 }
; }
L35:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\工作\video切换\soft\按键切换\test.c
_state::
	.blkb 1
	.dbsym e state _state c
_ICP_value_down::
	.blkb 2
	.dbsym e ICP_value_down _ICP_value_down i
_ICP_Flag::
	.blkb 1
	.dbsym e ICP_Flag _ICP_Flag c

⌨️ 快捷键说明

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