?? main.asm
字號:
//=====================================================================
// The information contained herein is the exclusive property of
// Sunnnorth Technology Co. And shall not be distributed, reproduced,
// or disclosed in whole in part without prior written permission.
// (C) COPYRIGHT 2003 SUNNORTH TECHNOLOGY CO.
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorized copies.
//======================================================================
//======================================================================
// 工程名稱: ex16_asm_UART
// 功能描述: 《實驗儀實驗指導書》基礎應用實驗
// UART
// 使用UART與上位機通訊,當收到上位機發送的數據時
// ,把接收到的數據發送到上位機,顯示在上位機串口
// 調試軟件上
// IDE環境: SUNPLUS u'nSPTM IDE 2.0.0(or later)
// PC機環境: 串口調試工具(PortExpert)
// 涉及的庫: CMacro1016.lib
// 組成文件: main.asm
// 硬件連接: 串口線連接計算機串口,COMM接口跳線跳接至RS232一端
// 維護記錄: 2005-09-12 v1.0
//
//=======================================================================
//=======================================================================
// 文件名稱: main.asm
// 功能描述: 使用UART與上位機通訊,當收到上位機發送的數據時
// ,把接收到的數據發送到上位機,顯示在上位機串口
// 調試軟件上
// 維護記錄: 2005-09-12 v1.0
//=======================================================================
.DEFINE P_IOB_Data 0x7005
.DEFINE P_IOB_Buffer 0x7006
.DEFINE P_IOB_Dir 0x7007
.DEFINE P_IOB_Attrib 0x7008
.DEFINE P_UART_Command1 0x7021
.DEFINE P_UART_Command2 0x7022
.DEFINE P_UART_Data 0x7023
.DEFINE P_UART_BaudScalarLow 0x7024
.DEFINE P_UART_BaudScalarHigh 0x7025
.DEFINE P_Watchdog_Clear 0x7012
.CODE
//=========================================================================
// 匯編格式: _main
// C格式: int main(void);
// 實現功能: 使用UART與上位機通訊,當收到上位機發送的數據時
// ,把接收到的數據發送到上位機,顯示在上位機串口
// 調試軟件上
// 入口參數: 無
// 出口參數: 無
// 破壞寄存器:r1,r2
//==========================================================================
.PUBLIC _main
_main:
r1 = 0x0480
[P_IOB_Attrib] = r1 //初始化IO口,IOB7懸浮輸入,IOB10高電平輸出
r1 = 0x0400
[P_IOB_Dir] = r1
r1 = 0x0400
[P_IOB_Data] = r1
r1 = 0x00 //設置波特率9600bps
[P_UART_BaudScalarLow] = r1
r1 = 0x05
[P_UART_BaudScalarHigh] = r1
r1 = 0x0000
[P_UART_Command1] = r1
r1 = 0x00c0 //輸入輸出使能
[P_UART_Command2] = r1
?Loop:
?RecWait:
r1 = 0x0001 //清看門狗
[P_Watchdog_Clear] = r1
r1 = [P_UART_Command2]
r1 &= 0x0080 //測試是否有數據接收?
jz ?RecWait
r1 = [P_UART_Data] //讀取UART緩沖區數據
?WaitTX:
r2 = 0x0001
[P_Watchdog_Clear] = r2
r2 = [P_UART_Command2]
test r2,0x0040 //測試當前發送是否忙?
jz ?WaitTX
[P_UART_Data] = r1 //發送數據
jmp ?Loop
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -