TI E2E™ 设计支持论坛将于 5 月 30 日至 6 月 1 日进行维护。如果您在此期间需要技术支持,请联系 TI 的客户支持中心寻求帮助。

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530接收BasicRF接收端数据字节大小的问题

Other Parts Discussed in Thread: CC2530

在用CC2530的BasicRF做通信的时候,发现当发送端一包数据发10个字节可以接收,发送20个字节就接收不到了。

对如下的接收程序进行分析,发现:

static void appLight()
{
// Initialize BasicRF
basicRfConfig.myAddr = RECEIVE_ADDR;
if(basicRfInit(&basicRfConfig)==FAILED) { //初始化basicRf数据结构
HAL_ASSERT(FALSE);
}
basicRfReceiveOn(); //允许接收

while (1) {
while(!basicRfPacketIsReady()); //检测是否接收到数据

//调用函数接收数据,接收完成置位
if(basicRfReceive(pRxData, APP_PAYLOAD_LENGTH, NULL)>0) { // receive data
UartSend_String("R:",2);
UartSend_String(pRxData,APP_PAYLOAD_LENGTH);
UartSend_String("\n",1);
LED2=!LED2;
}
}
}

发现:

1.当一包数据小于10个字节的时候,程序可以运行过while(!basicRfPacketIsReady()); 函数,并将接收的数据串口打印出来;

2.当一包数据大于10个字节的时候,程序卡在while(!basicRfPacketIsReady()); 函数,程序卡死,不运行了;

3.当一包数据大于10个字节的时候,将while(!basicRfPacketIsReady()); 注释了,串口可以打印出数据包中大于10个字节的数据;

求问这是什么问题?


  • 详细看下basicRfRxFrmDoneIsr(void)这个函数。

  • 我也知道是这个函数除了问题,但这个函数是你们给的库函数啊,我也不知道要更改哪里啊?求助啊?

    static void basicRfRxFrmDoneIsr(void)
    {
    basicRfPktHdr_t *pHdr;
    uint8 *pStatusWord;
    #ifdef SECURITY_CCM
    uint8 authStatus=0;
    #endif

    // Map header to packet buffer
    pHdr= (basicRfPktHdr_t*)rxMpdu;

    // Clear interrupt and disable new RX frame done interrupt
    halRfDisableRxInterrupt();

    // Enable all other interrupt sources (enables interrupt nesting)
    halIntOn();

    // Read payload length.
    halRfReadRxBuf(&pHdr->packetLength,1);
    pHdr->packetLength &= BASIC_RF_PLD_LEN_MASK; // Ignore MSB

    // Is this an acknowledgment packet?
    // Only ack packets may be 5 bytes in total.
    if (pHdr->packetLength == BASIC_RF_ACK_PACKET_SIZE) {

    // Read the packet
    halRfReadRxBuf(&rxMpdu[1], pHdr->packetLength);

    // Make sure byte fields are changed from network to host byte order
    UINT16_NTOH(pHdr->panId);
    UINT16_NTOH(pHdr->destAddr);
    UINT16_NTOH(pHdr->srcAddr);
    #ifdef SECURITY_CCM
    UINT32_NTOH(pHdr->frameCounter);
    #endif

    rxi.ackRequest = !!(pHdr->fcf0 & BASIC_RF_FCF_ACK_BM_L);

    // Read the status word and check for CRC OK
    pStatusWord= rxMpdu + 4;

    // Indicate the successful ACK reception if CRC and sequence number OK
    if ((pStatusWord[1] & BASIC_RF_CRC_OK_BM) && (pHdr->seqNumber == txState.txSeqNumber)) {
    txState.ackReceived = TRUE;
    }

    // No, it is data
    } else {

    // It is assumed that the radio rejects packets with invalid length.
    // Subtract the number of bytes in the frame overhead to get actual payload.

    rxi.length = pHdr->packetLength - BASIC_RF_PACKET_OVERHEAD_SIZE;

    #ifdef SECURITY_CCM
    rxi.length -= (BASIC_RF_AUX_HDR_LENGTH + BASIC_RF_LEN_MIC);
    authStatus = halRfReadRxBufSecure(&rxMpdu[1], pHdr->packetLength, rxi.length,
    BASIC_RF_LEN_AUTH, BASIC_RF_SECURITY_M);
    #else
    halRfReadRxBuf(&rxMpdu[1], pHdr->packetLength);
    #endif

    // Make sure byte fields are changed from network to host byte order
    UINT16_NTOH(pHdr->panId);
    UINT16_NTOH(pHdr->destAddr);
    UINT16_NTOH(pHdr->srcAddr);
    #ifdef SECURITY_CCM
    UINT32_NTOH(pHdr->frameCounter);
    #endif

    rxi.ackRequest = !!(pHdr->fcf0 & BASIC_RF_FCF_ACK_BM_L);

    // Read the source address
    rxi.srcAddr= pHdr->srcAddr;

    // Read the packet payload
    rxi.pPayload = rxMpdu + BASIC_RF_HDR_SIZE;

    // Read the FCS to get the RSSI and CRC
    pStatusWord= rxi.pPayload+rxi.length;
    #ifdef SECURITY_CCM
    pStatusWord+= BASIC_RF_LEN_MIC;
    #endif
    rxi.rssi = pStatusWord[0];

    // Notify the application about the received data packet if the CRC is OK
    // Throw packet if the previous packet had the same sequence number
    if( (pStatusWord[1] & BASIC_RF_CRC_OK_BM) && (rxi.seqNumber != pHdr->seqNumber) ) {
    // If security is used check also that authentication passed
    #ifdef SECURITY_CCM
    if( authStatus==SUCCESS ) {
    if ( (pHdr->fcf0 & BASIC_RF_FCF_BM_L) ==
    (BASIC_RF_FCF_NOACK_L | BASIC_RF_SEC_ENABLED_FCF_BM_L)) {
    rxi.isReady = TRUE;
    }
    }
    #else
    if ( ((pHdr->fcf0 & (BASIC_RF_FCF_BM_L)) == BASIC_RF_FCF_NOACK_L) ) {
    rxi.isReady = TRUE;
    }
    #endif
    }
    rxi.seqNumber = pHdr->seqNumber;
    }

    // Enable RX frame done interrupt again
    halIntOff();
    halRfEnableRxInterrupt();
    }

  • 你有源代码啊 想怎么改,怎么调试都可以啊,加断点一步步调么