zigbee CC2530的串口的发送的题型
题目:单片机,通过串口输出自己的姓名和学号
主要核心代码为配置zigbee串口的寄存器那里,一般为固定性的代码
#include <ioCC2530.h>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
uint count=0;
void init(void)
{
CLKCONCMD &=0X80;
T1CTL |=0X0E;//0000 1110 111--128 10--模模式
T1CCTL0 |=0X04;
T1CC0L=(50000&0XFF);
T1CC0H=((50000&0XFFAA)>>8);
T1STAT &=~0X01;
TIMIF &=~0X40;
IEN1 |=0X02;
EA=1;
PERCFG =0X00;
P0SEL |=0X3C;
U0CSR |=0X80;
U0UCR |=0X80;
U0BAUD=59;
U0GCR=8;
UTX0IF=0;
EA=1;
}
void sendstring(uchar *str)
{
while(*str!='\0')
{
U0DBUF=*str++;
while(!UTX0IF);
UTX0IF=0;
}
}
int main(void)
{
init();
while(1)
{
if (count>15)
{
count=0;
sendstring("韦xx");
sendstring("1617173101");
}
}
}
#pragma vector=T1_VECTOR
__interrupt void ti(void)
{
EA=0;
count++;
T1STAT&=~0X01;
EA=1;
}