Hi,
i wrote a radio code. My code dunction well. Now i want to add my uart code and see my data, coming from the one uC, on the pc. But i get only wrong data. If i test my code with SmartRF Studio7 than i can see that my code is right. Also i get the right data from the uC.
I configurate the baudrate to 1.2kHz for the radio and for the uart. But i see only wrong data coming.
Here my code:
SLEEP &= ~SLEEP_OSC_PD_BM;
while (!(SLEEP & SLEEP_XOSC_STB_BM));
CLKCON &= ~CLKCON_OSC_BM;
while (CLKCON & CLKCON_OSC_BM);
SLEEP |= SLEEP_OSC_PD_BM;
U0BAUD = 163;
U0GCR = (U0GCR&~0x1F) | 5; //baud rate 1200
PERCFG &= ~0x01;
// P0SEL.SELP0_2/3/4/5 = 1 => RX = P0_2, TX = P0_3, CT = P0_4, RT = P0_5
P0SEL |= 0x3C;
P1SEL &= ~0x3C;
U0CSR |= U0CSR_MODE;
U0UCR &= ~U0UCR_START;
U0UCR |= U0UCR_STOP;
U0UCR &= ~U0UCR_SPB;
U0UCR &= ~U0UCR_PARITY;
U0UCR &= ~U0UCR_BIT9;
U0UCR &= ~U0UCR_D9;
U0UCR &= ~U0UCR_FLOW;
U0GCR &= ~U0GCR_ORDER;
RFIF = 0x00;
RFTXRXIF = 0;
EA = 1;
while(1)
{
RFST = 0x02;
while (!RFTXRXIF);
RFTXRXIF = 0;
length = RFD;
rxBuffer[0] = length;
UTX0IF = 0;
U0CSR &= ~U0CSR_TX_BYTE;
for (uint8 j = 1; j <= length + 2; j++)
{
while (!RFTXRXIF);
RFTXRXIF = 0;
rxBuffer[j] = RFD;
uart[j] = RFD;
}
while ((RFIF & 0x10) == 0);
IEN2 |= IEN2_RFIE;
while(TX_Z<=length)
{
U0DBUF = uart[TX_Z];
TX_Z++;
}
TX_Z=1;
IEN2 |= IEN2_UTX0IE;
}
#pragma vector = RF_VECTOR
__interrupt void RF()
{
RFIF = 0;
IEN2 &= ~IEN2_RFIE;
}
#pragma vector = UTX0_VECTOR
__interrupt void UTX0(void)
{
UTX0IF = 0;
if (TX_Z > length)
{
TX_Z = 0;
IEN2 &= ~IEN2_UTX0IE;
return;
}
IEN2 &= ~IEN2_UTX0IE;
}
Please help!