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

📄 uart.s

📁 AVR单片机C语言程序设计实例精粹
💻 S
📖 第 1 页 / 共 4 页
字号:
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e sbGetTxBufferEmptyStatus _sbGetTxBufferEmptyStatus fc
;            ptr -> R16,R17
	.even
_sbGetTxBufferEmptyStatus::
	.dbline -1
	.dbline 289
; }
; 
; //********************************************************************
; // Function    : sbGetTxBufferNoEmptyStatus
; // Input       : ptr-pointer to SCI Buffer
; // Output      : Status of SCI TX Buffer
; // Description : Check whether the SCI TX Buffer is empty or not
; //********************************************************************
; INT8U sbGetTxBufferEmptyStatus(struct SCI_Buffer *ptr)
; {
	.dbline 290
; 	if(ptr->bTxBufferLength == 0)
	movw R30,R16
	ldd R2,z+2
	tst R2
	brne L34
	.dbline 291
; 	{
	.dbline 292
; 		return(true);
	ldi R16,1
	xjmp L33
L34:
	.dbline 294
; 	}
; 	return(false);
	clr R16
	.dbline -2
L33:
	.dbline 0 ; func end
	ret
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e sbGetRxBufferEmptyStatus _sbGetRxBufferEmptyStatus fc
;            ptr -> R16,R17
	.even
_sbGetRxBufferEmptyStatus::
	.dbline -1
	.dbline 304
; }
; 
; //********************************************************************
; // Function    : sbGetRxBufferEmptyStatus
; // Input       : ptr-pointer to SCI Buffer
; // Output      : Status of SCI TX Buffer
; // Description : Check whether the SCI TX Buffer is empty or not
; //********************************************************************
; INT8U sbGetRxBufferEmptyStatus(struct SCI_Buffer *ptr)
; {
	.dbline 305
; 	if(ptr->bRxLength == 0)
	movw R30,R16
	ldd R2,z+0
	tst R2
	brne L37
	.dbline 306
; 	{
	.dbline 307
; 		return(true);
	ldi R16,1
	xjmp L36
L37:
	.dbline 309
; 	}
; 	return(false);
	clr R16
	.dbline -2
L36:
	.dbline 0 ; func end
	ret
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e SciBuffer_Rx_Reset _SciBuffer_Rx_Reset fV
;            ptr -> R16,R17
	.even
_SciBuffer_Rx_Reset::
	.dbline -1
	.dbline 319
; }
; 
; //********************************************************************
; // Function    : SciBuffer_Rx_Reset
; // Input       : ptr-pointer to SCI Buffer
; // Output      : none
; // Description : Reset RX Buffer Length to zero
; //********************************************************************
; void SciBuffer_Rx_Reset(struct SCI_Buffer *ptr)
; {
	.dbline 320
; 	ptr->bRxLength = 0;
	clr R2
	movw R30,R16
	std z+0,R2
	.dbline -2
	.dbline 321
; }
L39:
	.dbline 0 ; func end
	ret
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e SciBuffer_Tx_Reset _SciBuffer_Tx_Reset fV
;            ptr -> R16,R17
	.even
_SciBuffer_Tx_Reset::
	.dbline -1
	.dbline 330
; 
; //********************************************************************
; // Function    : SciBuffer_Tx_Reset
; // Input       : ptr-pointer to SCI Buffer
; // Output      : none
; // Description : Reset TX Buffer Length to zero
; //********************************************************************
; void SciBuffer_Tx_Reset(struct SCI_Buffer *ptr)
; {
	.dbline 331
; 	ptr->bTxLength = 0;
	clr R2
	movw R30,R16
	std z+1,R2
	.dbline 332
; 	ptr->bTxBufferLength = 0;
	movw R30,R16
	std z+2,R2
	.dbline -2
	.dbline 333
; }
L40:
	.dbline 0 ; func end
	ret
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e SciBuffer_Tx_Inc _SciBuffer_Tx_Inc fV
;            ptr -> R16,R17
	.even
_SciBuffer_Tx_Inc::
	.dbline -1
	.dbline 342
; 
; //********************************************************************
; // Function    : SciBuffer_Tx_Inc
; // Input       : ptr-pointer to SCI Buffer
; // Output      : none
; // Description : Increase TX Buffer Length
; //********************************************************************
; void SciBuffer_Tx_Inc(struct SCI_Buffer *ptr)
; {
	.dbline 343
; 	ptr->bTxLength++;
	movw R24,R16
	adiw R24,1
	movw R30,R24
	ldd R24,z+0
	subi R24,255    ; addi 1
	std z+0,R24
	.dbline -2
	.dbline 344
; }
L41:
	.dbline 0 ; func end
	ret
	.dbsym r ptr 16 pX
	.dbend
	.dbfunc e UART_WRITE_DATA _UART_WRITE_DATA fV
;            ptr -> R20,R21
	.even
_UART_WRITE_DATA::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 353
; 
; //********************************************************************
; // Function    : UART_WRITE_DATA
; // Input       : ptr-pointer to SCI Buffer
; // Output      : none
; // Description : Send the firstIncrease TX Buffer Length
; //********************************************************************
; void UART_WRITE_DATA(struct SCI_Buffer *ptr)
; {
	.dbline 354
; 	UART_TX_DATA(ptr->bTxBuffer[0]);
	movw R30,R20
	ldd R16,z+53
	xcall _UART_TX_DATA
	.dbline 355
; 	SciBuffer_Tx_Inc(ptr);
	movw R16,R20
	xcall _SciBuffer_Tx_Inc
	.dbline 356
; 	Enable_UART_TX_INT();
	xcall _Enable_UART_TX_INT
	.dbline -2
	.dbline 357
; }
L42:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r ptr 20 pX
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\市电电压频率测量系统\UART.c
L44:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\市电电压频率测量系统\UART.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\市电电压频率测量系统\UART.c
	.dbfunc e C1Command _C1Command fV
	.dbsym s bCount L44 c
	.even
_C1Command::
	.dbline -1
	.dbline 366
; 
; //********************************************************************
; // Function    : C1Command
; // Input       : none
; // Output      : none
; // Description : C1
; //********************************************************************
; void C1Command(void)
; {
	.dbline 368
; 	static INT8U bCount = 0;
; 	bCount++;
	lds R24,L44
	subi R24,255    ; addi 1
	sts L44,R24
	.dbline 369
; 	if(bCount & 0x01)
	sbrs R24,0
	rjmp L45
	.dbline 370
; 	{
	.dbline 371
; 		Buzzer_ON();
	xcall _Buzzer_ON
	.dbline 372
; 	}
	xjmp L46
L45:
	.dbline 374
	.dbline 375
	xcall _Buzzer_OFF
	.dbline 376
L46:
	.dbline -2
	.dbline 377
; 	else
; 	{
; 		Buzzer_OFF();
; 	}
; }
L43:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e C2Command _C2Command fV
;          bChar -> y+0
	.even
_C2Command::
	sbiw R28,3
	.dbline -1
	.dbline 386
	.dbline 388
	lds R2,_stSciBuffer+3+2
	std y+0,R2
	.dbline 389
	lds R24,_stSciBuffer+3+3
	subi R24,48
	std y+1,R24
	.dbline 390
	lds R24,_stSciBuffer+3+4
	subi R24,48
	std y+2,R24
	.dbline 391
	ldd R24,y+0
	cpi R24,44
	brne L56
	ldi R24,9
	ldd R2,y+1
	cp R24,R2
	brlo L56
	ldd R2,y+2
	cp R24,R2
	brlo L56
	.dbline 392
	.dbline 393
	ldd R2,y+1
	ldi R24,10
	mul R24,R2
	mov R16,R0
	ldd R2,y+2
	add R16,R2
	xcall _sSet_Buzzer_Count
	.dbline 394
L56:
	.dbline -2
	.dbline 395
; 
; //********************************************************************
; // Function    : C2Command
; // Input       : none
; // Output      : none
; // Description : C2,MM
; //********************************************************************
; void C2Command(void)
; {
; 	INT8U bChar[3];
; 	bChar[0] = stSciBuffer.bRxBuffer[2];
; 	bChar[1] = stSciBuffer.bRxBuffer[3] - '0'; 
; 	bChar[2] = stSciBuffer.bRxBuffer[4] - '0'; 
; 	if((bChar[0] == ',') && (bChar[1] <= 9) && (bChar[2] <= 9))
; 	{
; 		sSet_Buzzer_Count(bChar[1] * 10 + bChar[2]);
; 	}
; }
L47:
	adiw R28,3
	.dbline 0 ; func end
	ret
	.dbsym l bChar 0 A[3:3]c
	.dbend
	.dbfunc e D1Command _D1Command fV
	.even
_D1Command::
	.dbline -1
	.dbline 404
; 
; //********************************************************************
; // Function    : D1Command
; // Input       : none
; // Output      : none
; // Description : D1
; //********************************************************************
; void D1Command(void)
; {
	.dbline 405
; 	SciBuffer_Tx_In(&stSciBuffer,'I');
	ldi R18,73
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 406
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 407
; 	SciBuffer_Tx_In(&stSciBuffer,'L');
	ldi R18,76
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 408
; 	SciBuffer_Tx_In(&stSciBuffer,'O');
	ldi R18,79
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 409
; 	SciBuffer_Tx_In(&stSciBuffer,'V');
	ldi R18,86
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 410
; 	SciBuffer_Tx_In(&stSciBuffer,'E');
	ldi R18,69
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 411
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 412
; 	SciBuffer_Tx_In(&stSciBuffer,'Y');
	ldi R18,89
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 413
; 	SciBuffer_Tx_In(&stSciBuffer,'O');
	ldi R18,79
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 414
; 	SciBuffer_Tx_In(&stSciBuffer,'U');
	ldi R18,85
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 415
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 416
; 	SciBuffer_Tx_In(&stSciBuffer,'!');
	ldi R18,33
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 417
; 	SciBuffer_Tx_In(&stSciBuffer,'\n');
	ldi R18,10
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 419
; 	
; 	UART_WRITE_DATA(&stSciBuffer);
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	.dbline -2
	.dbline 420
; }
L62:
	.dbline 0 ; func end
	xjmp _UART_WRITE_DATA
	.dbend
	.dbfunc e D2Command _D2Command fV
;         dwTest -> y+4
	.even
_D2Command::
	xcall push_gset2
	sbiw R28,8
	.dbline -1
	.dbline 429
; 
; //********************************************************************
; // Function    : D2Command
; // Input       : none
; // Output      : none
; // Description : D2
; //********************************************************************
; void D2Command(void)
; {
	.dbline 430
; 	INT32U dwTest = 0xFFFFFFFF; //4294967295
	ldi R20,255
	ldi R21,255
	ldi R22,255
	ldi R23,255
	movw R30,R28
	std z+4,R20
	std z+5,R21
	std z+6,R22
	std z+7,R23
	.dbline 432
; 	
; 	sDataToNumber(dwTest,10,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,10
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToNumber
	.dbline 433
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 435
; 	
; 	sDataToNumber(dwTest,4,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,4
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToNumber
	.dbline 436
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 438
; 	
; 	sDataToNumber(dwTest,2,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,2
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToNumber
	.dbline 439
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 441
; 
; 	sDataToNumber(dwTest,1,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,1
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToNumber
	.dbline 442
; 	SciBuffer_Tx_In(&stSciBuffer,'\n');
	ldi R18,10
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 444
; 	
; 	UART_WRITE_DATA(&stSciBuffer);
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _UART_WRITE_DATA
	.dbline -2
	.dbline 445
; }
L63:
	adiw R28,8
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l dwTest 4 l
	.dbend
	.dbfunc e D3Command _D3Command fV
;         dwTest -> y+4
	.even
_D3Command::
	xcall push_gset2
	sbiw R28,8
	.dbline -1
	.dbline 454
; 
; //********************************************************************
; // Function    : D3Command
; // Input       : none
; // Output      : none
; // Description : D3
; //********************************************************************
; void D3Command(void)
; {
	.dbline 455
; 	INT32U dwTest = 0x12345678;
	ldi R20,120
	ldi R21,86
	ldi R22,52
	ldi R23,18
	movw R30,R28
	std z+4,R20
	std z+5,R21
	std z+6,R22
	std z+7,R23
	.dbline 457
; 	
; 	sDataToChar(dwTest,8,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,8
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToChar
	.dbline 458
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 460
; 	
; 	sDataToChar(dwTest,4,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,4
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToChar
	.dbline 461
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 463
; 	
; 	sDataToChar(dwTest,2,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,2
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToChar
	.dbline 464
; 	SciBuffer_Tx_In(&stSciBuffer,' ');
	ldi R18,32
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 466
; 	
; 	sDataToChar(dwTest,1,&stSciBuffer);
	ldi R24,<_stSciBuffer
	ldi R25,>_stSciBuffer
	std y+3,R25
	std y+2,R24
	ldi R24,1
	std y+0,R24
	movw R30,R28
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _sDataToChar
	.dbline 467
; 	SciBuffer_Tx_In(&stSciBuffer,'\n');
	ldi R18,10
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _SciBuffer_Tx_In
	.dbline 469
; 	
; 	UART_WRITE_DATA(&stSciBuffer);
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	xcall _UART_WRITE_DATA
	.dbline -2
	.dbline 470
; }
L64:
	adiw R28,8
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l dwTest 4 l
	.dbend
	.dbfunc e XXCommand _XXCommand fV
	.even
_XXCommand::
	.dbline -1
	.dbline 479
; 
; //********************************************************************
; // Function    : XXCommand
; // Input       : none
; // Output      : none
; // Description : XX
; //********************************************************************
; void XXCommand(void)
; {
	.dbline 480
; 	sStringToChar("Received XX Command.\n",&stSciBuffer);
	ldi R18,<_stSciBuffer
	ldi R19,>_stSciBuffer
	ldi R16,<L66
	ldi R17,>L66
	xcall _sStringToChar
	.dbline 481
; 	UART_WRITE_DATA(&stSciBuffer);	
	ldi R16,<_stSciBuffer
	ldi R17,>_stSciBuffer
	.dbline -2
	.dbline 482
; }
L65:
	.dbline 0 ; func end
	xjmp _UART_WRITE_DATA
	.dbend
	.dbfunc e YYCommand _YYCommand fV
;          bChar -> y+0
	.even
_YYCommand::
	sbiw R28,3
	.dbline -1
	.dbline 491
; 
; //********************************************************************
; // Function    : YYCommand
; // Input       : none
; // Output      : none
; // Description : YY,MM
; //********************************************************************
; void YYCommand(void)
; {
	.dbline 493
; 	INT8U bChar[3];
; 	bChar[0] = stSciBuffer.bRxBuffer[2];
	lds R2,_stSciBuffer+3+2

⌨️ 快捷键说明

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