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

📄 test_usart.s

📁 ad7135的avr16的源程序
💻 S
字号:
	.module test_usart.c
	.area text(rom, con, rel)
	.dbfile test_usart.c
	.dbfunc e DELAY_1MS _DELAY_1MS fV
;              i -> R16,R17
	.even
_DELAY_1MS::
	.dbline -1
	.dbline 25
; //************************************************* 
; //测试功能:下位机往上位机发送数据
; //测试方法:串口调试助手
; //测试结果:OK
; //时钟频率:外部8m
; //管脚分配:
; //注意事项: 
; //完成时间:2009.03.15 
; //**************************************************
; 
; //************************************************** 
; //头文件
; //************************************************** 
; #include <iom16v.h>
; #include <macros.h>
; //**************************************************
; 
;  
; //********************************************************** 
; //函数名称:void DELAY_1MS(void)
; //函数功能:延时1ms
; //注意事项:i=143*n-2
; //********************************************************** 
; void DELAY_1MS(void)
; {    
	.dbline 27
; 	 unsigned int i;
; 	 for(i=1142;i>0;i--)    
	ldi R16,1142
	ldi R17,4
	xjmp L5
L2:
	.dbline 28
L3:
	.dbline 27
	subi R16,1
	sbci R17,0
L5:
	.dbline 27
	cpi R16,0
	cpc R16,R17
	brne L2
X0:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e DELAY_NMS _DELAY_NMS fV
;              n -> R20,R21
	.even
_DELAY_NMS::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 36
;      ;
; }
; //********************************************************** 
; //函数名称:void DELAY_1MS(void)
; //函数功能:延时1ms
; //注意事项:i=143*n-2
; //********************************************************** 
; void DELAY_NMS(unsigned int n)
; {	 
	.dbline 37
; 	 for(;n>0;n--)
	xjmp L10
L7:
	.dbline 38
	xcall _DELAY_1MS
L8:
	.dbline 37
	subi R20,1
	sbci R21,0
L10:
	.dbline 37
	cpi R20,0
	cpc R20,R21
	brne L7
X1:
	.dbline -2
L6:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r n 20 i
	.dbend
	.dbfunc e USART_INIT _USART_INIT fV
	.even
_USART_INIT::
	.dbline -1
	.dbline 46
; 	      DELAY_1MS();
; }
; //***************************************************** 
; //函数名称:void USART_INIT(void) 
; //函数功能:8M,波特率9600
; //注意事项:
; //*****************************************************
; void USART_INIT(void)
; {	 
	.dbline 47
; 	 UBRR=0X33;//fosc=8mhz,波特率9600
	ldi R24,51
	out 0x9,R24
	.dbline 48
; 	 UCSRA=0X20;
	ldi R24,32
	out 0xb,R24
	.dbline 49
; 	 UCSRC=0X86;
	ldi R24,134
	out 0x20,R24
	.dbline 50
; 	 UCSRB=0X98;
	ldi R24,152
	out 0xa,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e USART_TX _USART_TX fV
;           data -> R20
	.even
_USART_TX::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 58
; }
; //***************************************************** 
; //函数名称:void USART_INIT(void) 
; //函数功能:8M,波特率9600
; //注意事项:
; //*****************************************************
; void USART_TX(unsigned char data)
; {	 
	.dbline 59
; 	 UDR=data;
	out 0xc,R20
L13:
	.dbline 61
L14:
	.dbline 60
; 	 while(!(UCSRA&(1<<TXC)))
	sbis 0xb,6
	rjmp L13
	.dbline 62
; 	 ;
; 	 DELAY_NMS(1);
	ldi R16,1
	ldi R17,0
	xcall _DELAY_NMS
	.dbline -2
L12:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e DATA_DISPLAY _DATA_DISPLAY fV
;           temp -> y+0
;              i -> R10
;           data -> y+16
	.even
_DATA_DISPLAY::
	xcall push_arg4
	xcall push_gset3
	sbiw R28,10
	.dbline -1
	.dbline 70
; }
; //***************************************************** 
; //函数名称:void USART_INIT(void) 
; //函数功能:8M,波特率9600
; //注意事项:
; //*****************************************************
; void DATA_DISPLAY(unsigned long int data)
; {	 
	.dbline 72
; 	 unsigned char temp[10],i;
; 	 temp[0]=(data/1000000000);
	ldi R20,0
	ldi R21,202
	ldi R22,154
	ldi R23,59
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	std y+0,R16
	.dbline 73
; 	 temp[1]=(data/100000000)%10;
	ldi R20,0
	ldi R21,225
	ldi R22,245
	ldi R23,5
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+1,R16
	.dbline 74
; 	 temp[2]=(data/10000000)%10;
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+2,R16
	.dbline 75
; 	 temp[3]=(data/1000000)%10;
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+3,R16
	.dbline 76
; 	 temp[4]=(data/100000)%10;
	ldi R20,160
	ldi R21,134
	ldi R22,1
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+4,R16
	.dbline 77
; 	 temp[5]=(data/10000)%10;
	ldi R20,16
	ldi R21,39
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+5,R16
	.dbline 78
; 	 temp[6]=(data/1000)%10;
	ldi R20,232
	ldi R21,3
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+6,R16
	.dbline 79
; 	 temp[7]=(data/100)%10;
	ldi R20,100
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+7,R16
	.dbline 80
; 	 temp[8]=(data/10)%10;
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32u
	std y+8,R16
	.dbline 81
; 	 temp[9]=data%10;
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall mod32u
	std y+9,R16
	.dbline 82
; 	 for(i=0;i<10;i++)
	clr R10
	xjmp L29
L26:
	.dbline 83
	.dbline 84
	movw R24,R28
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _USART_TX
	.dbline 85
	ldi R16,1
	ldi R17,0
	xcall _DELAY_NMS
	.dbline 86
L27:
	.dbline 82
	inc R10
L29:
	.dbline 82
	mov R24,R10
	cpi R24,10
	brlo L26
	.dbline -2
L16:
	adiw R28,10
	xcall pop_gset3
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l temp 0 A[10:10]c
	.dbsym r i 10 c
	.dbsym l data 16 l
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 92
; 	 {
; 	      USART_TX(temp[i]);
; 		  DELAY_NMS(1);
; 	 }
; }
; //************************************************** 
; //主函数
; //**************************************************
; void main(void)
; {	 
	.dbline 93
; 	 USART_INIT();
	xcall _USART_INIT
	.dbline 94
; 	 DATA_DISPLAY(4294967295);
	ldi R16,255
	ldi R17,255
	ldi R18,255
	ldi R19,255
	xcall _DATA_DISPLAY
L31:
	.dbline 96
L32:
	.dbline 95
	xjmp L31
X2:
	.dbline -2
L30:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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