Other Parts Discussed in Thread: CC2530, TIMAC, Z-STACK
Dear all:
void InitUart(void)
{
PERCFG = 0x00;
P0SEL |= 0x30; //P0_4,P0_5 as uart1
P2DIR &= ~0xC0;
U1CSR |= 0x80;
U1GCR |= 11;
U1BAUD |= 216; //115200
UTX1IF = 0;
U1CSR |= 0x40;
IEN0 |= 0x88;
}
#pragma vector = URX1_VECTOR
__interrupt void UART1_ISR(void)
{
URX1IF = 0;
RxBuf = U1DBUF;
}
void UartSendString(char *Data, int len)
{
uint i;
for(i=0; i<len; i++)
{
U1DBUF = *Data++;
while(UTX1IF == 0);
UTX1IF = 0;
}
}
void main(void)
{
char RxData[TX_SIZE];
unsigned char count=0;
CLKCONCMD &= ~0x40;
while(CLKCONSTA & 0x40);
CLKCONCMD &= ~0x47;
InitUart();
memset(RxData, 0, TX_SIZE);
memset(TxData, 0, TX_SIZE);
memcpy(TxData, TX_STRING, sizeof(TX_STRING));
UartSendString("hello ", 6);
while(1)
{
if(RxBuf != 0)
{
if((RxBuf != '#')&&(count < 10))
RxData[count++] = RxBuf;
else
{
UartSendString(RxData, count); //send msg back to PC
count = 0;
}
RxBuf = 0;
}
}
}
the uart1 can send message and the PC serial port assistant can print messge :hello
but the cc2530 can't recv any message from PC serial port.
Best Regards & thanks
JKing