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

📄 060_单片机与pc机通信.s

📁 一般的单片机与PC机之间的串口通信
💻 S
字号:
	.module _060_单片机与PC机通信.c
	.area text(rom, con, rel)
	.dbfile D:\BKF\N_HDJ\单片机学习开发系统板资料\SP0602_AVR-II\SP0602AVR-II开发板\C源程序\060_单片机与PC机通信\060_单片机与PC机通信.c
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 9
; //ICC-AVR application builder : 2006-3-9 12:06:43
; // Target : M8515
; // Crystal: 4.0000Mhz
; 
; #include <iom8515v.h>
; #include <macros.h>
; 
; void port_init(void)
; {
	.dbline 10
;   PORTA = 0x01;
	ldi R24,1
	out 0x1b,R24
	.dbline 11
;   DDRA  = 0x01;
	out 0x1a,R24
	.dbline 12
;   PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 13
;   DDRB  = 0x00;
	out 0x17,R2
	.dbline 14
;   PORTC = 0x00;
	out 0x15,R2
	.dbline 15
;   DDRC  = 0x00;
	out 0x14,R2
	.dbline 16
;   PORTD = 0x00;
	out 0x12,R2
	.dbline 17
;   DDRD  = 0x00; 
	out 0x11,R2
	.dbline 18
;   PORTE = 0x00;
	out 0x7,R2
	.dbline 19
;   DDRE  = 0x00; 
	out 0x6,R2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 23
; }
; 
; void uart0_init(void)
; {
	.dbline 24
;   UCSRB = 0x00;
	clr R2
	out 0xa,R2
	.dbline 25
;   UCSRA = 0x00;
	out 0xb,R2
	.dbline 26
;   UCSRC = BIT(URSEL) | 0x06;
	ldi R24,134
	out 0x20,R24
	.dbline 27
;   UBRRL = 0x19;
	ldi R24,25
	out 0x9,R24
	.dbline 28
;   UBRRH = 0x00;
	out 0x20,R2
	.dbline 29
;   UCSRB = 0xD8;
	ldi R24,216
	out 0xa,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 18
	rjmp _uart0_rx_isr
	.area text(rom, con, rel)
	.dbfile D:\BKF\N_HDJ\单片机学习开发系统板资料\SP0602_AVR-II\SP0602AVR-II开发板\C源程序\060_单片机与PC机通信\060_单片机与PC机通信.c
	.dbfunc e uart0_rx_isr _uart0_rx_isr fV
;           Temp -> R16
	.even
_uart0_rx_isr::
	st -y,R16
	in R16,0x3f
	st -y,R16
	.dbline -1
	.dbline 34
; }
; 
; #pragma interrupt_handler uart0_rx_isr:10
; void uart0_rx_isr(void)
; {
	.dbline 37
;   unsigned char Temp;
;   
;   Temp=UDR;
	in R16,0xc
	.dbline 38
;   if(Temp=='A')
	cpi R16,65
	brne L4
	.dbline 39
;     {
	.dbline 40
; 	  if((PINA & 0x01)==0)
	sbic 0x19,0
	rjmp L6
	.dbline 41
; 	    {
	.dbline 42
; 		  PORTA|=BIT(PORTA0);
	sbi 0x1b,0
	.dbline 43
; 		}
	rjmp L7
L6:
	.dbline 45
; 		else
; 		  {
	.dbline 46
; 		    PORTA&=~BIT(PORTA0);
	cbi 0x1b,0
	.dbline 47
; 		  }
L7:
	.dbline 48
L4:
	.dbline -2
L3:
	ld R16,y+
	out 0x3f,R16
	ld R16,y+
	.dbline 0 ; func end
	reti
	.dbsym r Temp 16 c
	.dbend
	.area vector(rom, abs)
	.org 22
	rjmp _uart0_tx_isr
	.area text(rom, con, rel)
	.dbfile D:\BKF\N_HDJ\单片机学习开发系统板资料\SP0602_AVR-II\SP0602AVR-II开发板\C源程序\060_单片机与PC机通信\060_单片机与PC机通信.c
	.dbfunc e uart0_tx_isr _uart0_tx_isr fV
	.even
_uart0_tx_isr::
	.dbline -1
	.dbline 53
; 	}
; }
; 
; #pragma interrupt_handler uart0_tx_isr:12
; void uart0_tx_isr(void)
; {
	.dbline -2
L8:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 60
;  //character has been transmitted
; }
; 
; 
; 
; void init_devices(void)
; {
	.dbline 61
;   CLI();
	cli
	.dbline 62
;   port_init();
	rcall _port_init
	.dbline 63
;   uart0_init();
	rcall _uart0_init
	.dbline 65
;   
;   MCUCR = 0x00;
	clr R2
	out 0x35,R2
	.dbline 66
;   EMCUCR = 0x00;
	out 0x36,R2
	.dbline 67
;   GICR = 0x00;
	out 0x3b,R2
	.dbline 68
;   TIMSK = 0x00;
	out 0x39,R2
	.dbline 69
;   SEI();
	sei
	.dbline -2
L9:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 77
; }
; 
; 
; 
; 
; 
; void main(void)
; {
	.dbline 78
;   init_devices();
	rcall _init_devices
L11:
	.dbline 81
	.dbline 82
	.dbline 83
L12:
	.dbline 80
	rjmp L11
X0:
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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