CC2530————向PC端发送数据(中断方式)

#include<iocc2530.h>
#include<string.h>
#define LED1 P1_5
#define LED2 P1_0
#define LED3 P1_4
#define LED4 P1_3
#define uchar unsigned char
#define uint unsigned int
char Data[]=“Hellosp”;
uint count=0;
void Delay(uint time)
{
uint i;
uchar j;
for(i=0;i<time;i++)
for(j=0;j<240;j++)
{
asm(“NOP”);
asm(“NOP”);
asm(“NOP”);
}
}
void UARTInt(void)
{
CLKCONCMD&=0X80;
P0SEL|=0X0C;
U0CSR|=0X80;
U0GCR|=10;
U0BAUD|=216;
UTX0IF=0;
EA=1;

}
void InitT1(void)
{
T1CTL|=0X0E;
T1CCTL0|=0X04;
T1CC0L|=50000&0XFF;
T1CC0H|=(500000&0XFF00)>>8;
TIMIF&=~0X40;
IEN1|=0X02;
EA=1;

}
void UART_Send_String(char *Data,int lenth)
{
int i;
for(i=0;i<lenth;i++)
{
U0DBUF=*Data++;
while(UTX0IF==0)
UTX0IF=0;
}
}
#pragma vector=T1_VECTOR
__interrupt void T1INT(void)
{
count++;
}
main()
{
P0DIR|=0X39;
P0&=~0X39;
UARTInt();
InitT1();
while(1)
{
if(count>=15)
{
count=0;
UART_Send_String(Data,strlen(Data));
LED1=!LED1;
}
}
}

猜你喜欢

转载自blog.csdn.net/News53231323/article/details/113244077
今日推荐