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.

CC2640R2F: rfPacketTx with 2M phy (RF_MODE_BLE), how to increase payload size?

Part Number: CC2640R2F

Hi Champs,

I am testing rfPacketTx/Rx with CC2640R2F launchpad.

For high speed 2Mbps PHY, I used "RF_MODE_BLE" RF settings from SmartRF Studio 7.

With rfPacketTx/Rx example application, I want to increase the packet payload size.

(The example does not use BLE Stack, but Bluetooth 5 Advertising Extension can send up to 255 bytes payload.)

So, what is the maximum payload size with rfPacketTx/Rx example applications with 2Mbps PHY of BLE mode?

Can you guide how to do the test of rfPacketTx/Rx with increased payload size?

Thanks and regards,

Hayden

  • Hi Hayden,

    The default rfPcketTx/Rx supports uses the propTx/Rx radio commands and support up to 30 bytes payload.

    It should not be hard to increase the maximum size of the payload, you would have to increase the "PAYLOAD_LENGTH" in the TX example and "MAX_LENGTH" in the RX example to start with.
  • Hello,

    For 2Mbps (high speed) mode, I want to use "RF_MODE_BLE" not "RF_MODE_PROPRIETARY_2_4".
    So, I could not use "RF_cmdPropTx" of proprietary Tx/Rx command.
    I want to use both 2Mbps and increased payload size.

    Thanks and regards,
    Hayden
  • You can combine the 2 Mbps BLE settings with the HS API. The ordinary prop API (CMD_PROP_RX and CMD_PROP_TX) cannot be used at data rates higher that 1 Mbps. Use SmartRF Studio to export the BLE setup command and the overrides needed for 2 Mbps and change .rfMode to RF_MODE_PROPRIETARY_2_4.

    Below is a TX example modified to use the HS API:

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    #include "rf_hs_mailbox.h"
    
    /* Board Header files */
    #include "Board.h"
    #include "smartrf_settings/smartrf_settings.h"
    #include "RFQueue.h"
    
    /***** Defines *****/
    
    /* Packet TX Configuration */
    #define PAYLOAD_LENGTH          30              // Length of the packet to send
    #define DATA_ENTRY_HEADER_SIZE  8               // Constant header size of a Generic Data Entry
    #define MAX_LENGTH              PAYLOAD_LENGTH  // Set the length of the data entry
    #define NUM_DATA_ENTRIES        1
    #define NUM_APPENDED_BYTES      0
    #define PACKET_INTERVAL         (uint32_t)(4000000*0.1f) /* Set packet interval to 100 ms */
    #define PACKET_COUNT            2500
    
    /***** Prototypes *****/
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    static uint16_t seqNumber;
    
    #if defined(__TI_COMPILER_VERSION__)
        #pragma DATA_ALIGN (txDataEntryBuffer, 4);
            static uint8_t txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                                            MAX_LENGTH,
                                                                            NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
        #pragma data_alignment = 4
            static uint8_t txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                                            MAX_LENGTH,
                                                                            NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
            static uint8_t txDataEntryBuffer [RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                                            MAX_LENGTH,
                                                                            NUM_APPENDED_BYTES)] __attribute__ ((aligned (4)));
    #else
        #error This compiler is not supported.
    #endif
            
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t *pPacket;
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        uint32_t curtime;
        uint16_t count = 0;
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
        
        if( RFQueue_defineQueue(&dataQueue,
                                txDataEntryBuffer,
                                sizeof(txDataEntryBuffer),
                                NUM_DATA_ENTRIES,
                                MAX_LENGTH + NUM_APPENDED_BYTES))
        {
            /* Failed to allocate space for all data entries */
            while(true);
        }
    
        RF_cmdTxHS.pQueue = &dataQueue;
        RF_cmdTxHS.startTrigger.triggerType = TRIG_ABSTIME;
        RF_cmdTxHS.startTrigger.pastTrig = 1;
        RF_cmdTxHS.startTime = 0;
        
        currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer;
        currentDataEntry->length = PAYLOAD_LENGTH;
        pPacket = &currentDataEntry->data;
        
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_ble, (RF_RadioSetup*)&RF_cmdBle5RadioSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        /* Get current time */
        curtime = RF_getCurrentTime();
        while(count++ < PACKET_COUNT)
        {
            /* Create packet with incrementing sequence number and random payload */
            pPacket[0] = (uint8_t)(seqNumber >> 8);
            pPacket[1] = (uint8_t)(seqNumber++);
            uint8_t i;
            for (i = 2; i < PAYLOAD_LENGTH; i++)
            {
                pPacket[i] = i - 1;
            }
    
            /* Set absolute TX time to utilize automatic power management */
            curtime += PACKET_INTERVAL;
            RF_cmdTxHS.startTime = curtime;
    
            /* Send packet */
            RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdTxHS,
                                                       RF_PriorityNormal, NULL, 0);
    
            switch(terminationReason)
            {
                case RF_EventCmdDone:
                    // A radio operation command in a chain finished
                    break;
                case RF_EventLastCmdDone:
                    // A stand-alone radio operation command or the last radio
                    // operation command in a chain finished.
                    break;
                case RF_EventCmdCancelled:
                    // Command cancelled before it was started; it can be caused
                // by RF_cancelCmd() or RF_flushCmd().
                    break;
                case RF_EventCmdAborted:
                    // Abrupt command termination caused by RF_cancelCmd() or
                    // RF_flushCmd().
                    break;
                case RF_EventCmdStopped:
                    // Graceful command termination caused by RF_cancelCmd() or
                    // RF_flushCmd().
                    break;
                default:
                    // Uncaught error event
                    while(1);
            }
    
            uint32_t cmdStatus = ((volatile RF_Op*)&RF_cmdTxHS)->status;
            switch(cmdStatus)
            {
                case HS_DONE_OK:
                    // Operation ended normally
                    break;
                case HS_DONE_STOPPED:
                    // Operation stopped after stop command
                    break;
                case HS_DONE_ABORT:
                    // Operation aborted by abort command
                    break;
                case HS_ERROR_PAR:
                    // Illegal parameter
                    break;
                case HS_ERROR_NO_SETUP:
                    // Radio was not set up in a compatible mode
                    break;
                case HS_ERROR_NO_FS:
                    // Synth was not programmed when running Rx or Tx
                    break;
                case HS_ERROR_TXUNF:
                    // Tx underflow observed during operation
                    break;
                case HS_DONE_TXBUF:
                    // Tx queue was empty at start of operation
                    break;
                default:
                    // Uncaught error event - these could come from the
                    // pool of states defined in rf_hs_mailbox.h
                    while(1);
            }
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
        }
        RF_yield(rfHandle);
        while(1);
    }
    
    

    Siri