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

📄 led.s

📁 51单片机的
💻 S
📖 第 1 页 / 共 5 页
字号:
	.dbline 446
;    LED_DATA_PORTA&=0X00;
	clr R2
	out 0x1b,R2
	.dbline 447
;    LED_DATA_PORTA|=LED_DATA[LED_DISPLAY_V3];
	ldi R24,<_LED_DATA
	ldi R25,>_LED_DATA
	lds R30,_LED_DISPLAY_V3
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	in R3,0x1b
	or R3,R2
	out 0x1b,R3
	.dbline 448
;    LED_SCAN_PORTB&=~LED_V3;       //PB2=0
	cbi 0x18,2
	.dbline 449
;    if (JS_001>=23)
	lds R24,_JS_001
	cpi R24,23
	brlo L84
	.dbline 450
;        HC573_CLK_PORTC&=~HC573_CLK;     // PC4 =0
	cbi 0x15,4
	xjmp L83
L84:
	.dbline 452
;    else 
;        HC573_CLK_PORTC|=HC573_CLK;     // PC4 =1
	sbi 0x15,4
	.dbline 453
;    } 
	xjmp L83
L82:
	.dbline 454
; else if (JS_001>30,JS_001<=40)
	ldi R24,40
	lds R2,_JS_001
	cp R24,R2
	brlo L86
	.dbline 455
;    {
	.dbline 456
;    HC573_CLK_PORTC|=HC573_CLK;     // PC4 =1
	sbi 0x15,4
	.dbline 457
;    LED_SCAN_PORTB=0xff;
	ldi R24,255
	out 0x18,R24
	.dbline 458
;    LED_DATA_PORTA&=0X00;
	clr R2
	out 0x1b,R2
	.dbline 459
;    LED_DATA_PORTA|=LED_DATA[LED_DISPLAY_V4];
	ldi R24,<_LED_DATA
	ldi R25,>_LED_DATA
	lds R30,_LED_DISPLAY_V4
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	in R3,0x1b
	or R3,R2
	out 0x1b,R3
	.dbline 460
;    LED_SCAN_PORTB&=~LED_V4;       //PB3=0
	cbi 0x18,3
	.dbline 461
;    if (JS_001>=33)
	lds R24,_JS_001
	cpi R24,33
	brlo L88
	.dbline 462
;        HC573_CLK_PORTC&=~HC573_CLK;     // PC4 =0
	cbi 0x15,4
	xjmp L87
L88:
	.dbline 464
;    else 
;        HC573_CLK_PORTC|=HC573_CLK;     // PC4 =1
	sbi 0x15,4
	.dbline 465
;    }     
	xjmp L87
L86:
	.dbline 466
; else if (JS_001>40,JS_001<=50)
	ldi R24,50
	lds R2,_JS_001
	cp R24,R2
	brlo L90
	.dbline 467
;    {
	.dbline 468
;    HC573_CLK_PORTC|=HC573_CLK;     // PC4 =1
	sbi 0x15,4
	.dbline 469
;    LED_SCAN_PORTB=0xff;
	ldi R24,255
	out 0x18,R24
	.dbline 470
;    LED_DATA_PORTA|=0Xff;
	in R24,0x1b
	ori R24,255
	out 0x1b,R24
	.dbline 471
;    LED_DATA_PORTA&=LED_DATA[LED_DISPLAY_V5];
	ldi R24,<_LED_DATA
	ldi R25,>_LED_DATA
	lds R30,_LED_DISPLAY_V5
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	in R3,0x1b
	and R3,R2
	out 0x1b,R3
	.dbline 472
;    LED_SCAN_PORTB&=~LED_V5;       //PB4=0
	cbi 0x18,4
	.dbline 473
;    if (JS_001>=43)
	lds R24,_JS_001
	cpi R24,43
	brlo L92
	.dbline 474
;        HC573_CLK_PORTC&=~HC573_CLK;     // PC4 =0
	cbi 0x15,4
	xjmp L93
L92:
	.dbline 476
;    else 
;        HC573_CLK_PORTC|=HC573_CLK;     // PC4 =1
	sbi 0x15,4
L93:
	.dbline 477
;    if (JS_001==50)
	lds R24,_JS_001
	cpi R24,50
	brne L94
	.dbline 478
;        JS_001&=0; 
	clr R2
	sts _JS_001,R2
L94:
	.dbline 479
;    }
L90:
L87:
L83:
L79:
L75:
	.dbline -2
	.dbline 481
; 
; }
L73:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 548
; /*
; ////////////////////////////TIMER1///////////////////////////////////////////////////////////////////////////
; //TIMER1 initialize - prescale:Falling edge
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 0Hz
; // actual value: Out of range
; void timer1_init(void)
; {
;  TCCR1B = 0x00; //stop
;  TCNT1H = 0x00 ; //setup
;  TCNT1L = 0x00 ;
;  OCR1AH = 0x00 ;
;  OCR1AL = 0x00 ;
;  OCR1BH = 0x00 ;
;  OCR1BL = 0x00 ;
; // OCR1CH = $OCR1CH$;
; // OCR1CL = $OCR1CL$;
;  ICR1H  = 0x00 ;
;  ICR1L  = 0x00 ;
;  TCCR1A = 0x00;
;  TCCR1B = 0x87; //start Timer   详见p173  ICP 选上升沿触发  47 87
; }
; /*
; ///////////////////////ICP_INPUT//////////////////////////////////////////////
; #pragma interrupt_handler timer1_capt_isr:6                                 
; void timer1_capt_isr(void)
; {
;  //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
;   //LED_DISPLAY_V4=8;          //TEST  OK
;   JS_TIMER1_ICP_INPUT=++JS_TIMER1_ICP_INPUT;    //8 bit  IR INT/TIMES  ++
;        
;    ICP_INT_SN=1;         //ICP 产生中断标志位
; 
;       
;   OUT_22_LOW=JS_TIMER1_ICP_INPUT;  // 记数 二进制显示  test use
;   LED_DISPLAY_V1=(OUT_22_LOW>>3)&0X01;   
;   OUT_22_LOW=JS_TIMER1_ICP_INPUT;     
;   LED_DISPLAY_V2=(OUT_22_LOW>>2)&0X01;
;   OUT_22_LOW=JS_TIMER1_ICP_INPUT;
;   LED_DISPLAY_V3=(OUT_22_LOW>>1)&0X01;
;   OUT_22_LOW=JS_TIMER1_ICP_INPUT;
;   LED_DISPLAY_V4=OUT_22_LOW&0X01;
;   LED_DISPLAY_V5=15;       
;        
; }
;   
;     
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
;  //TIMER1 has overflowed
;  TCNT1H = 0x00; //reload counter high value
;  TCNT1L = 0x00; //reload counter low value
;  
; }
; */
; ////////////////////////////UART0//////////////////////////////////////////////////////////////////////
; 
; //UART0 initialize
; // desired baud rate: 250000
; // actual: baud rate:250000 (0.0%)
; // char size: 9 bit
; // parity: Odd
; void uart0_init(void)
; {
	.dbline 549
;  UCSRB = 0x00; //disable while setting baud rate
	clr R2
	out 0xa,R2
	.dbline 550
;  UCSRA = 0x03;
	ldi R24,3
	out 0xb,R24
	.dbline 551
;  UCSRC = BIT(URSEL) | 0x36;
	ldi R24,182
	out 0x20,R24
	.dbline 552
;  UBRRL = 0x07; //set baud rate lo
	ldi R24,7
	out 0x9,R24
	.dbline 553
;  UBRRH = 0x00; //set baud rate hi
	out 0x20,R2
	.dbline 554
;  UCSRB = 0xFC;
	ldi R24,252
	out 0xa,R24
	.dbline -2
	.dbline 555
; }
L96:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 44
	jmp _uart0_rx_isr
	.area text(rom, con, rel)
	.dbfile D:\WORK\ELECTR~1\proteus\M167LE~1\c\led.c
	.dbfunc e uart0_rx_isr _uart0_rx_isr fV
	.even
_uart0_rx_isr::
	.dbline -1
	.dbline 560
; 
; 
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; {
	.dbline -2
	.dbline 562
;  //uart has received a character in UDR
; }
L97:
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 48
	jmp _uart0_udre_isr
	.area text(rom, con, rel)
	.dbfile D:\WORK\ELECTR~1\proteus\M167LE~1\c\led.c
	.dbfunc e uart0_udre_isr _uart0_udre_isr fV
	.even
_uart0_udre_isr::
	.dbline -1
	.dbline 566
; 
; #pragma interrupt_handler uart0_udre_isr:13
; void uart0_udre_isr(void)
; {
	.dbline -2
	.dbline 568
;  //character transferred to shift register so UDR is now empty
; }
L98:
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 52
	jmp _uart0_tx_isr
	.area text(rom, con, rel)
	.dbfile D:\WORK\ELECTR~1\proteus\M167LE~1\c\led.c
	.dbfunc e uart0_tx_isr _uart0_tx_isr fV
	.even
_uart0_tx_isr::
	.dbline -1
	.dbline 572
; 
; #pragma interrupt_handler uart0_tx_isr:14
; void uart0_tx_isr(void)
; {
	.dbline -2
	.dbline 574
;  //character has been transmitted
; }
L99:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 578
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 580
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 581
;  port_init();
	xcall _port_init
	.dbline 583
; //watchdog_init();
;  timer0_init();
	xcall _timer0_init
	.dbline 585
; 
;  uart0_init();
	xcall _uart0_init
	.dbline 587
;  
;  MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 588
;  GICR  = 0x00;
	out 0x3b,R2
	.dbline 589
;  TIMSK = 0x25; //timer interrupt sources
	ldi R24,37
	out 0x39,R24
	.dbline 590
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
	.dbline 592
;  //all peripherals are now initialized
; }
L100:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 596
; 
; ////////////////////////MAIN////////////////////////////////////////////////////////////////////
; void main(void)
; {
	.dbline 599
;   
;  
;  init_devices();
	xcall _init_devices
	xjmp L103
L102:
	.dbline 601
;  while (1)
;  {
	.dbline 602
;  if (bIrCmdOk) CheckIrCmd();
	lds R2,_bIrCmdOk
	tst R2
	breq L105
	.dbline 602
	xcall _CheckIrCmd
L105:
	.dbline 603
;  if (bCmdOk) ReadCmd();
	lds R2,_bCmdOk
	tst R2
	breq L107
	.dbline 603
	xcall _ReadCmd
L107:
	.dbline 604
L103:
	.dbline 600
	xjmp L102
X2:
	.dbline -2
	.dbline 618
;  }
;  
;  //insert your functional code here...
;  
;   
;  //while(N_001<=100)
;  //{
;  //      N_001=N_001+SUM;
;  //}
; 
;   //insert your functional code here...
;  
;  
;  
; } 
L101:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e display_times _display_times fV
;          temp3 -> R20
;          temp1 -> R20
;          temp2 -> R22
	.even
_display_times::
	xcall push_gset2
	.dbline -1
	.dbline 621
;       
; void display_times()     //输入三位10进制&8位无符号数 (0xef) 用led 输出 成功
; {
	.dbline 623
; char temp1,temp2,temp3;
;            temp1=iIrData[0]>>4;
	.dbline 624
;            temp2=iIrData[0]>>4;
	.dbline 627
;            //temp1=(iIrData[2]+(iIrData[1]>>4));
;            //temp2=(iIrData[2]+(iIrData[1]>>4));
;            LED_DISPLAY_V2=temp1/100;
	.dbline 628
;            temp2=temp2%100;
	.dbline 629
;            temp3=temp2;
	.dbline 630
;            LED_DISPLAY_V3=temp2/10;
	.dbline 631
;            LED_DISPLAY_V4=temp3%10;
	lds R24,_iIrData
	swap R24
	andi R24,#0x0F
	mov R22,R24
	ldi R17,100
	mov R16,R24
	xcall div8u
	sts _LED_DISPLAY_V2,R16
	ldi R17,100
	mov R16,R22
	xcall mod8u
	mov R22,R16
	mov R20,R22
	ldi R17,10
	xcall div8u
	sts _LED_DISPLAY_V3,R16
	ldi R17,10
	mov R16,R20
	xcall mod8u
	sts _LED_DISPLAY_V4,R16
	.dbline -2
	.dbline 633
;          // LED_DISPLAY_V4=6; //testy
; }
L109:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r temp3 20 c
	.dbsym r temp1 20 c
	.dbsym r temp2 22 c
	.dbend
	.dbfunc e CheckIR _CheckIR fV
	.even
_CheckIR::
	.dbline -1
	.dbline 637
; 
; //红外解码
; void CheckIR()
; {
	.dbline 639
;    //uchar iNowBit,iPos;
;   if ((PIND&(1<<IR))>0)    //ICP INPUT CHECK
	clr R2
	in R24,0x10
	andi R24,64
	cp R2,R24
	brsh L111
	.dbline 640
;        iNowBit=0;
	sts _iNowBit,R2
	xjmp L112
L111:
	.dbline 642
;    else 
;      iNowBit=1;//先反相
	ldi R24,1
	sts _iNowBit,R24
L112:
	.dbline 645
;    
;    //把信号持续的处理作为公共处理
;    if ((iPreBit==1)&&(iNowBit==1))//hight++  
	lds R24,_iPreBit
	cpi R24,1
	brne L113
	lds R24,_iNowBit
	cpi R24,1
	brne L113
	.dbline 646
; 		  { iHight++;
	.dbline 646
	.dbline 647
; 		    return;
	lds R24,_iHight
	subi R24,255    ; addi 1
	sts _iHight,R24
	xjmp L110
L113:
	.dbline 649
; 		  }
;    if ((iPreBit==0)&&(iNowBit==0))//low++
	lds R2,_iPreBit
	tst R2
	brne L115
	lds R2,_iNowBit
	tst R2
	brne L115
	.dbline 650
; 		  { iLow++;
	.dbline 650
	.dbline 651
; 		    return;
	lds R24,_iLow
	subi R24,255    ; addi 1
	sts _iLow,R24
	xjmp L110
L115:
	.dbline 654
; 		  }
; 		  
;    switch (iIrMode)
	lds R16,_iIrMode
	clr R17
	cpi R16,0
	cpc R16,R17
	breq L120
X3:
	cpi R16,1
	ldi R30,0
	cpc R17,R30
	breq L127
	cpi R16,2
	ldi R30,0
	cpc R17,R30
	brne X7
	xjmp L135
X7:
	xjmp L117
X4:
	.dbline 655
;    {
L120:
	.dbline 657
;      case 0://等待9ms的高电平
; 	      if ((iPreBit==0)&&(iNowBit==1))//0->1:start
	lds R2,_iPreBit
	tst R2
	brne L121
	lds R24,_iNowBit
	cpi R24,1
	brne L121
	.dbline 658
; 		  { iPreBit=1;
	.dbline 658
	.dbline 659
; 		    iHight=1;
	.dbline 660
; 			return;
	ldi R24,1
	sts _iPreBit,R24
	sts _iHight,R24
	xjmp L110
L121:
	.dbline 663
; 		  }
; 		  
; 		  if ((iPreBit==1)&&(iNowBit==0))//1->0
	lds R24,_iPreBit
	cpi R24,1
	breq X8
	xjmp L118
X8:
	lds R2,_iNowBit
	tst R2
	breq X9

⌨️ 快捷键说明

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