已回答假定已回答

ADUCRF101通信距离很短

sdzhangyuyin1@126.com 在 2014-1-19 詢問的問題
最後回覆由ADI_XUN於2014-1-22提供

发送端代码:

int main(void)

{

  int data[12]={0};

  RIE_Responses RIE_Response = RIE_Success;

  WdtGo(T3CON_ENABLE_DIS);

            //uart-----start

            Urt_Init(UART_BAUD_19200);

          Urt_PinSetup(FALSE);  

          printf("**************************\r\n");

          printf("\r\n    TX发送端初始化完成 \r\n");

          printf("**************************\r\n");

            //uart-----end

  // Initialise the Radio

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioInit(DR_38_4kbps_Dev19_2kpbs);     

  // Set the Frequency to operate at 915 MHz

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioSetFrequency(915000000);

  // Set the PA and Power Level

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioTxPacketFixedLen(12, "HELLO WORLD");

  printf("\n输入要发送的数据:");

  while (1)

  {   

    Delay1();

    RadioTxPacketFixedLen(12, "hello 123456");

  }

}

 

接收端代码:

int main(void)

{

  unsigned char  Buffer[0x20];

  RIE_U8         PktLen;

  RIE_S8         RSSI;

 

  RIE_U8 flag=0;

 

 

  RIE_Responses RIE_Response = RIE_Success;

  WdtGo(T3CON_ENABLE_DIS);

          //---------------UART code start---------------------

          Urt_Init(UART_BAUD_19200);

          Urt_PinSetup(FALSE);

          printf("\r\n**************************\r\n");

          printf("\r\n    RX接收端初始化完成!\n\r");

          printf("\r\n**************************\r\n");

          //-----------------UART code end---------------------

 

  // Initialise the Radio

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioInit(DR_38_4kbps_Dev19_2kpbs);     

  // Set the Frequency to operate at 915 MHz

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioSetFrequency(915000000);

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioRxPacketFixedLen(12);

 

 

          printf("\n\r正在接收数据\n\r");

  if (RIE_Response == RIE_Success)

     {

               while (!RadioRxPacketAvailable());

     }

  if (RIE_Response == RIE_Success)

     RIE_Response = RadioRxPacketRead(sizeof(Buffer),

                                      &PktLen,

                                      Buffer,

                                      &RSSI);

 

 

  if (RIE_Response == RIE_Success)

     printf("\n\r-> %s @ RSSI %d",Buffer,(int)RSSI);

  else

     printf("\n\r-> ERROR");

  while(1)

  {

          //-------------接收数据----------------

          RIE_Response = RadioRxPacketFixedLen(12);

          if (RIE_Response == RIE_Success)

               {

                         while (!RadioRxPacketAvailable());

               }

          if (RIE_Response == RIE_Success)

                         RIE_Response = RadioRxPacketRead(sizeof(Buffer),

                                      &PktLen,

                                      Buffer,

                                      &RSSI);

          //-------------------------------------- 

          printf("\n\r收到的数据:%s RSSI:%d",Buffer,(int)RSSI);

  }

}

 

发送端和接收端的代码如上所附,通信时通信距离只有十几厘米,是不是有需要

注意的地方我没有注意到,期待解答。

結果