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

📄 usart.s

📁 增量式模糊PID控制方法AVR单片机mega16
💻 S
字号:
	.module usart.c
	.area text(rom, con, rel)
	.dbfile D:\仿真\增量式模糊控制\usart.c
	.dbfunc e put_char _put_char fV
;             ch -> R16
	.even
_put_char::
	.dbline -1
	.dbline 4
; #define USART_C
; #include "includes.h"
; void put_char(unsigned char ch)
; {
L2:
	.dbline 9
L3:
	.dbline 9
;    /* if(ch == '\n')
;     {
;         usart_putchar('\r');
;     } */      
;     while(!(UCSRA&(1<<UDRE)));   
	sbis 0xb,5
	rjmp L2
	.dbline 10
;     UDR = ch;     
	out 0xc,R16
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r ch 16 c
	.dbend
	.dbfunc e put_string _put_string fV
;         string -> R20,R21
	.even
_put_string::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 13
; }
; void put_string(unsigned char *string)
; {
	xjmp L7
L6:
	.dbline 15
	.dbline 16
	movw R30,R20
	ld R16,Z+
	movw R20,R30
	xcall _put_char
	.dbline 17
L7:
	.dbline 14
;     while(*string)
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L6
	.dbline -2
L5:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r string 20 pc
	.dbend
	.dbfunc e InitSerial _InitSerial fV
	.even
_InitSerial::
	.dbline -1
	.dbline 20
;     {
;         put_char(*string++);
;     }    
;  }
; void InitSerial(void)	//串口初始化
; {
	.dbline 28
; 	// 晶振频率 : 4.0MHz
; 	// 通信参数: 8 Data, 1 Stop, No Parity 
; 	// 波特率:
; 	// UBRRL= 0x0C    19200;
; 	// UBRRL= 0x19    9600;
; 	// UBRRL= 0x33    4800;
; 	// UBRRL= 0x67    2400	
; 	UCSRB = (1<<RXEN)|(1<<TXEN)|(1<<RXCIE);  //允许发送和接收
	ldi R24,152
	out 0xa,R24
	.dbline 29
; 	UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0); //8位数据位+1位停止位
	ldi R24,134
	out 0x20,R24
	.dbline 31
; 	//UBRRH = 0x00; //set baud rate hi
; 	UBRRL=0x19;  
	ldi R24,25
	out 0x9,R24
	.dbline -2
L9:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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