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.

CC1312R: transmission of data which is 1000 byte length stops after 4 minute

Part Number: CC1312R

Hello All,

I have a custom board which based on cc1312R. I have RF_Buffer which has1000 byte length (one packet). I am transmitting this buffer to the receiver one time in every 8 second. Rf_buffer contains only fixed number.

I am able to send this buffer during around 4 minute. For one minute 7-8 packet,  totally I could send 28-30 packet. But after that there is no more transmission. Because The program doesnt enter inside txtaskfunction anymore.

I use this parameters.


#define TX_STACK_SIZE 512

PAYLOAD_LENGTH = 1000

unsigned char RF_Buffer[PAYLOAD_LENGTH+2];

void txTaskFunction(UArg arg0, UArg arg1)
{
    uint16_t index_2;
    uint32_t RFtime;
    RF_Params rfParams;
    RF_Params_init(&rfParams);

    if( RFQueue_defineQueue(&dataQueue,
            rxDataEntryBuffer,
            sizeof(rxDataEntryBuffer),
            NUM_DATA_ENTRIES,
            MAX_LENGTH + NUM_APPENDED_BYTES))
    {   while(1);}

    RF_cmdPropTxAdv.pktLen =  PAYLOAD_LENGTH+2;
    RF_cmdPropTxAdv.pPkt = RF_Buffer;
    RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropTxAdv.startTrigger.pastTrig = 1;

    if (!rfHandle){
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    }
    RFtime = RF_getCurrentTime();

    while(1)
    {
        Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);
        {
            RF_Buffer[1]=(uint8_t)(PAYLOAD_LENGTH >> 8);
            RF_Buffer[0]=(uint8_t)(PAYLOAD_LENGTH);

            for(index_2 = 2; index_2 < PAYLOAD_LENGTH+2; index_2 ++)
            {
                RF_Buffer[index_2] = ALL_Buffer[index_2-2];
            }
            RF_Buffer[1000]='\r';
            RF_Buffer[1001]='\n';
            RFtime += PACKET_INTERVAL;
            RF_cmdPropTxAdv.startTime = RFtime;

            RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);

            if (!(result & RF_EventLastCmdDone))
            {   while(1);}
        }
        memset(RF_Buffer, 0, sizeof(RF_Buffer));
        PIN_setOutputValue(hPin, STA_LED,!PIN_getOutputValue(STA_LED));
    }
}

What do you think about this problem? what can it be block data trasmission or to enter inside txtaskfunction after  minute.

thank you 

BR

Bekir

  • Hi

    How can you know that you are not entering the txtaskfunction ? Are there other tasks that are running or do you base this on the fact that your receiver stops receiving? Have you checked that your stacks are big enough etc.?

    I am kind of that you are able to receive the packets sent with the code above.

    You write:

    RF_Buffer[0] = 0xE8

    and

    RF_Buffer[1] = 0x03 instead of the other way around.

    At least with my RX code (when using a 2 bytes long header), this will be interpreted as 0xE803 (and not 0x03E8), and the packet will be filtered away since my code does not accept length bytes that long.

    Below is some code I tested (both RX and TX) to see if I could send/receive packets of length 1000:

    // TX
    
    #define PAYLOAD_LENGTH          1000    // Max 255 if SIZE_OF_LENGHT_FIELD = 1
    #define PACKET_INTERVAL         500000  // Set packet interval to 500 ms
    
    /***** Prototypes *****/
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    static uint8_t packet[PAYLOAD_LENGTH + 2];
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        CONFIG_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH + 2;
        RF_cmdPropTxAdv.pPkt = packet;
        RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_NOW;
        RF_cmdPropTxAdv.condition.rule = 1;
        RF_cmdPropTxAdv.pktConf.bUseCrc = 1;
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        while(1)
        {
            uint16_t i;
    
            packet[0] = (uint8_t)(PAYLOAD_LENGTH >> 8);
            packet[1] = (uint8_t)(PAYLOAD_LENGTH);
    
            for (i = 2; i < PAYLOAD_LENGTH + 2; i++)
            {
                packet[i] = 0x55;
            }
    
            /* Send packet */
            RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
    
            PIN_setOutputValue(ledPinHandle, CONFIG_PIN_GLED,!PIN_getOutputValue(CONFIG_PIN_GLED));
    
            /* Power down the radio */
            RF_yield(rfHandle);
    
            /* Sleep for PACKET_INTERVAL us */
            usleep(PACKET_INTERVAL);
    
            while(1);
        }
    }

    // RX
    
    #define DATA_ENTRY_HEADER_SIZE 8   /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             1000 /* Max length byte the radio will accept */
                                       /* Must be less than 256 if SIZE_OF_LENGHT_FIELD = 1 */
    #define NUM_DATA_ENTRIES       2   /* NOTE: Only two data entries supported at the moment */
    #define SIZE_OF_LENGHT_FIELD   2
    #define NUM_APPENDED_BYTES     1 +  SIZE_OF_LENGHT_FIELD /* The Data Entries data field will contain:
                                                              * 1 or 2 header byte(s) (containing the length)
                                                              * A maximum of MAX_LENGTH payload bytes
                                                              * 1 status byte (RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1) */
    
    
    
    /***** Prototypes *****/
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    /* Buffer which contains all Data Entries for receiving data.
     * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[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
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[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
    
    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint16_t packetLength;
    static uint8_t* packetDataPointer;
    static rfc_propRxOutput_t rxStatistics;
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES];
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        CONFIG_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    	PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        if( RFQueue_defineQueue(&dataQueue,
                                rxDataEntryBuffer,
                                sizeof(rxDataEntryBuffer),
                                NUM_DATA_ENTRIES,
                                MAX_LENGTH + NUM_APPENDED_BYTES))
        {
            /* Failed to allocate space for all data entries */
            while(1);
        }
    
        /* Modify CMD_PROP_RX command for application needs */
        /* Set the Data Entity queue for received data */
        RF_cmdPropRxAdv.pQueue = &dataQueue;
        /* Discard ignored packets from Rx queue */
        RF_cmdPropRxAdv.rxConf.bAutoFlushIgnored = 1;
        /* Discard packets with CRC error from Rx queue */
        RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 1;
        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
        RF_cmdPropRxAdv.pktConf.bRepeatOk = 1;
        RF_cmdPropRxAdv.pktConf.bRepeatNok = 1;
        RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
    
        RF_cmdPropRxAdv.condition.rule = 1;
        RF_cmdPropRxAdv.pktConf.bUseCrc = 0x1;
        RF_cmdPropRxAdv.rxConf.bIncludeHdr = 0x1;
        RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1;
        RF_cmdPropRxAdv.endTrigger.triggerType = 0x1;
        RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
    
        RF_cmdPropRxAdv.hdrConf.numHdrBits = 16;
        RF_cmdPropRxAdv.hdrConf.numLenBits = 16;
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        /* Enter RX mode and stay forever in RX */
        RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
        while(1);
    }
    
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventRxEntryDone)
        {
            /* Toggle pin to indicate RX */
            PIN_setOutputValue(ledPinHandle, CONFIG_PIN_RLED,
                               !PIN_getOutputValue(CONFIG_PIN_RLED));
    
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            packetLength = ((uint16_t)((*(uint8_t*)(&currentDataEntry->data+1)) << 8) |
                            (uint16_t)(*(uint8_t*)(&currentDataEntry->data)));
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + SIZE_OF_LENGHT_FIELD);
    
            /* Copy the payload and the status bytes to the packet variable */
            memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - SIZE_OF_LENGHT_FIELD));
        }
        RFQueue_nextEntry();
    }

    Siri

  • Thank you for the answer, There are 3 reason caused me think to not enter to the txTaskFunction.First The Receiver stops receiving data. Second,As you can see the code in the txTaskFunc, I put there led blink code. so led also stop blinking after 4 minute with rf. it never blink again. and I also checked by debugging that whether I enter inside txTaskFunction or not, After 4 minute I didnt also enter into the function.

    The problem may be because of my stacks. But I dont know how to check, is it big enough or not, How can i check this? and can you show me what is your stack and how full it is.

    thank you

  • You can start by increasing #define TX_STACK_SIZE 512 and see if that changes anything. If not, I strongly recommend you to test the code I posted, as this code is verified to work. You should use the rfPacketRX and rfPacketTX as a starting point. Once you have that up and running, you can start modify it towards your application, and see whats steps make the code fail.

    Siri

  • I set TX_STACK_SIZE = 512, 1024,2048 respectively but nothing is changed.I am going to test as you said from starting point. For now I see this error in ROV after stop sending data.

    do This graphs tell us something about what the problem is? and do we have to set something in arm linker?

    thank you.

  • Unfortunately, I could not tell what the problem is based on your input. As I said, I would strongly recommend that you start from the rfPacketRX and/or rfPacketTX examples, and implement the changes you need. Start by just sending any receiving the packets as shown in my previous post. If you run into problems when starting to change your code after that, it will be easier for us to reproduce it and debug it here, if we then can do the same changes to the same examples, and see the same failure here.

    Siri

  • Hi Siri

    I found the problem what it is. the reason of the problem was RFtime = RF_getCurrentTime(); I was putting this command outside thw while(1). When it filled, it was not clearing. So I put rftime inside while(1). and now it is going to clear/reset. now problem is gone.

  • Glad you were able to get it up and running .

    BR

    Siri