📄 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 + -