#include <iocc2530.h>
#include <string.h>
#include "send.h"
#include "LED.h"
#define SIZE 101
char Buf = '\0';
char UartState;
uint count=0;
char Data[SIZE];
char s[] = "The data RX\TX go\n";
void main (void)
{
InitLED(LED0);
InitUart(USART0,11,216); //调用串口初始化函数
UartState = RX; //串口0默认处于接收模式
SetLED(LED0,ON);
DelayMS(1000);
SetLED(LED0,OFF);
UartSendString(s);
while(1)
{
if(UartState==RX) //接收状态
{
if(Buf != '\0')
{
if((Buf != '#')) //以'#'为结束符
Data[count++] =Buf;
else
{
if(count >= SIZE)
{
count =0; //计数清0
memset(Data,'\0',SIZE);//清空接收缓冲区
}
else
UartState = TX; //进入发送状态
}
Buf ='\0';
}
}
if(UartState==TX) //发送状态
{
U0CSR &=~0x40; //禁止接收
Data[count]='\n'; //添加换行
UartSendString(Data); //发送已记录的字符串。
U0CSR |= 0x40; //允许接收
UartState=RX; //恢复到接收状态
count =0; //计数清0
memset(Data, '\0',SIZE); //清空接收缓冲区
}
}
}
#pragma vector = URX0_VECTOR
__interrupt void UART0_ISR(void)
{
URX0IF = 0; // 清中断标志
Buf =U0DBUF;
LED0_PRO = ~LED0_PRO;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Serial.zip (34个子文件)
Serial.ewd 49KB
Serial.dep 6KB
Serial.ewt 157KB
BuildLog.log 3B
Serial.ewp 79KB
settings
Serial.Debug.cspy.ps1 1KB
Serial.Debug.general.xcl 247B
Serial.wsdt 27KB
Serial.dbgdt 45KB
Serial.Debug.cspy.bat 1KB
Serial.Debug.driver.xcl 473B
Serial.dnx 2KB
Serial.eww 160B
send_test.c 1KB
Debug
List
Serial.map 41KB
Exe
Serial.d51 30KB
Obj
send_test.pbi.xcl 15KB
LED.pbi.xcl 15KB
LED.r51 4KB
Serial.pbd.linf 185B
leds.r51 4KB
send.pbi.xcl 15KB
send_test.r51 17KB
send.pbi 72KB
leds.pbi.xcl 15KB
send.r51 10KB
send_test.pbi 73KB
Serial.pbd.browse 104KB
LED.pbi 40KB
Serial.pbd 104KB
source
send.c 1KB
LED.c 791B
Serial_drv
send.h 539B
LED.h 425B
共 34 条
- 1
资源评论
不会创建对象
- 粉丝: 511
- 资源: 31
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功