#include<ioCC2541.h>
void usart_init(void)
{
CLKCONCMD&=~(1<<6); //系统主时钟选择32MHZ
while(CLKCONSTA&(1<<6));//等待晶振稳定
CLKCONCMD&=~(7<<0); //当前时钟速度为32MHZ
U0CSR|=1<<7; //选择串口模式
PERCFG=0X00; //选择uart0的1位置
P0SEL|=(0X03<<2); //USART0的位置1:P0_2--RX,P0_3--TX;USART1的位置2:P0_5--RX,P0_4--TX;
P2DIR&=~(3<<6); //设定优先级1st priority: USART 0 2nd priority: USART 1 3rd priority: Timer 1
U0GCR=9; //选择波特率
U0BAUD=59;
UTX0IF=0; // 清除串口0的中断标志
U0CSR|=1<<6; //接收使能
URX0IE=1; //接收中断使能
EA=1; //打开总中断
}
void Uart_TX(char *p,int len)
{
unsigned int i;
for( i = 0; i < len; i++)
{
U0DBUF = *p++;
while(!UTX0IF);//等待发送完毕
UTX0IF = 0;
}
U0DBUF=0X0A; //换行
while(!UTX0IF);
UTX0IF=0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
USART_TEST.zip (25个子文件)
USART_TEST
uart_text.ewt 109KB
main.c 676B
uart_text.dep 3KB
usart.c 890B
usart.h 100B
settings
uart_text.Debug.driver.xcl 650B
uart_text.Debug.cspy.bat 1KB
uart_text.wspos 50B
uart_text.wsdt 3KB
uart_text.Debug.general.xcl 207B
uart_text.dni 684B
uart_text.dbgdt 63B
uart_text.ewp 59KB
uart_text.eww 163B
Debug
List
uart_text.map 37KB
Exe
uart_text.hex 13KB
Obj
main.pbi 37KB
uart_text.pbd 35KB
usart.pbi.cout 14KB
usart.r51 5KB
main.pbi.cout 14KB
usart.pbi 30KB
main.r51 9KB
uart_text.pbd.browse 35KB
uart_text.ewd 37KB
共 25 条
- 1
资源评论
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功