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.

LAUNCHXL-CC1310: RfPacketRX and FatFS won't work together (NORTOS)

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Good afternoon,

I have an issue and I can't seem to find why it won't work.

I have an SD card module attached to the SPI pins of the CC1310 launchpad. When using the code snippit below, I can open the SD card, create a file, write in it and close it. This works perfectly fine.

/*
 *  ======== sdraw.c ========
 */

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <String.h>
/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SD.h>
#include <ti/display/Display.h>
#include <third_party/fatfs/ff.h>
#include <third_party/fatfs/diskio.h>
#include <third_party/fatfs/ffcio.h>
#include <third_party/fatfs/ffconf.h>
#include "ti/drivers/SDFatFS.h"
/* Example/Board Header files */
#include "Board.h"


int32_t fatfs_getFatTime(void){
time_t seconds;
uint32_t fatTime;
struct tm *pTime;

        /*
         *  TI time() returns seconds elapsed since 1900, while other tools
         *  return seconds from 1970.  However, both TI and GNU localtime()
         *  sets tm tm_year to number of years since 1900.
         */
        seconds = time(NULL);

        pTime = localtime(&seconds);

        /*
         *  localtime() sets pTime->tm_year to number of years
         *  since 1900, so subtract 80 from tm_year to get FAT time
         *  offset from 1980.
         */
        fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
            ((uint32_t)(pTime->tm_mon) << 21) |
            ((uint32_t)(pTime->tm_mday) << 16) |
            ((uint32_t)(pTime->tm_hour) << 11) |
            ((uint32_t)(pTime->tm_min) << 5) |
            ((uint32_t)(pTime->tm_sec) >> 1);

        return ((int32_t)fatTime);
}


SDFatFS_Object myObj;
SDFatFS_Config SDFatFS_config[] =
     {
         { &myObj },
         NULL
     };
uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;


void createTxtFileOnSD(uint32_t BASEID, float data, uint32_t IDSENSOR, uint8_t time, uint8_t date){
    FIL fsrc;  /* File objects */
    FRESULT fr;          /* FatFs function common result code */
    UINT bw;         /* File read/write count */



    SD_init();
    SDFatFS_Handle sd_handle;
    SDFatFS_init();

    sd_handle = SDFatFS_open(Board_SD0,0);
       if (sd_handle == NULL)
       {

       }

       uint32_t TXTID = BASEID;
       int TXTFILENAME;
       char TXTNAME[15];
       TXTFILENAME = snprintf(TXTNAME, 15, "%d.txt", TXTID);

       fr = f_open(&fsrc, TXTNAME, FA_OPEN_EXISTING | FA_WRITE);
           switch (fr)
           {
               case FR_NO_FILE:
               fr = f_open(&fsrc, TXTNAME, FA_CREATE_NEW | FA_WRITE);

               case FR_OK:

                   f_open(&fsrc, TXTNAME, FA_OPEN_APPEND | FA_WRITE);
               default:
               break;
           }

           if(fr != 0)
           {

           }

           char buffer[100];
           char buffer2[100];
           int cx;
           int cx2;
           int counter = 0;

           while(counter <1)
           {
               cx = snprintf (buffer, sizeof(buffer), "\{\"%d\":\[", BASEID);
               cx2 = snprintf (buffer2, sizeof(buffer2),  "\"ID\":\"%d\"\,    \"Data\":%0.2f\," "\"time\":\"%d\"\, \"date\":\"%d\"\}\]\}\r\n", IDSENSOR, data, time, date);

               fr = f_write(&fsrc, buffer, cx, &bw);
               fr = f_write(&fsrc, buffer2, cx2, &bw);
               CPUdelay(8000 * (100));
               counter++;

               if(fr != 0)
               {

               }

                            /* Try to sync */
               fr = f_sync(&fsrc);
               if(fr != 0){

               }



           }
           /* Close open files */
fr =     f_close(&fsrc);


}



void *mainThread(void *arg0)
{

    Display_init();
    GPIO_init();


uint32_t BASEID = 113400;
uint32_t SENSID = 123;
uint32_t SENSID2 = 1234;
float temperature = 34.9;
float temperature2 = 35.7;
uint8_t time = 13;
uint8_t date = 15;
createTxtFileOnSD(BASEID, temperature, SENSID, time, date);
createTxtFileOnSD(BASEID, temperature2, SENSID2, time, date);
createTxtFileOnSD(BASEID, temperature, SENSID, time, date);

return(NULL);

}

In the code below, I receive an RF packet, decode and unpack it using my custom libraries and code, and then move on to the next packet in the queue. This works perfectly fine as well.

/*
 * Copyright (c) 2019, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>


/* TI Drivers */
#include <time.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/gpio.h>
/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)

/* Board Header files */
#include "Board.h"

/* Application Header files */
#include "RFQueue.h"
#include "smartrf_settings/smartrf_settings.h"



/* Custom header files*/
#include <Manchester.h>
#include <CRC8.h>




/***** Defines *****/

/* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE 9  /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH             19 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                   * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                   * Max 30 payload bytes
                                   * 1 status byte (RF_cmdPropRx.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 uint8_t packetLength;
static uint8_t* packetDataPointer;
uint8_t payload[19];



static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
uint16_t count = 0;
void toggle();
void toggle(){


 

    uint8_t CRC_OK_NOK = 0;
        float DataCalc = 0;
        float degC = 0;
        float hum = 0;
        float vbat = 0;

        uint8_t LENGTH =0;
        uint8_t ID0=0;
        uint8_t ID1=0;
        uint8_t ID2=0;
        uint32_t ID_FULL = 0;
        uint8_t TYPE=0;
        uint8_t DATA0=0;
        uint8_t DATA1=0;
        uint16_t DATA_FULL = 0;
        uint8_t CRC=0;
        uint8_t nCRC=0;
        uint32_t temp_id = 0;
        uint16_t temp_id5 = 0;
        int c = 0;
            for (c = 0; c < 19; c++)
            {
                  payload[c] = manDecode(packet[c]);

            }
            LENGTH |= payload[0];
                 LENGTH <<= 4;
                 LENGTH |= payload[1];

                 GPIO_toggle(Board_GPIO_RLED);

                 if(LENGTH == 5){

                                    ID0 |= payload[4];
                                    ID0 <<= 4;
                                    ID0 |= payload[5];

                                    ID1 |= payload[2];
                                    ID1 <<= 4;
                                    ID1 |= payload[3];

                                    DATA0 |= payload[6];
                                    DATA0 <<= 4;
                                    DATA0 |= payload[7];

                                    DATA1 |= payload[8];
                                    DATA1 <<= 4;
                                    DATA1 |= payload[9];


                                    CRC |= payload[10];
                                    CRC <<= 4;
                                    CRC |= payload[11];

                                    CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0);

                                    DATA_FULL |= DATA0;
                                    DATA_FULL <<=8;
                                    DATA_FULL |= DATA1;
                                    DataCalc = DATA_FULL;

                                    ID_FULL |= ID0;
                                    ID_FULL <<=8;
                                    ID_FULL |= ID1;

                                    if(CRC_OK_NOK == 1)
                                    {
                                    DataCalc /= 100;
                                    DataCalc *=0.78125;

                                    // IF LAATSTE BIT ID 1 IS DAN IS HET TEMP
                                    temp_id5 = ID_FULL;
                                    temp_id5 <<= 15;
                                    temp_id5 >>= 15;
                                    if(temp_id5 == 1)
                                    {
                                    degC = DataCalc;

                                    }
                                    else
                                    {
                                        hum = DataCalc;

                                    }

                               }

                       }

                 if(LENGTH == 7)
                         {

                                  ID0 |= payload[6];
                                  ID0 <<= 4;
                                  ID0 |= payload[7];

                                  ID1 |= payload[4];
                                  ID1 <<= 4;
                                  ID1 |= payload[5];

                                  ID2 |= payload[2];
                                  ID2 <<= 4;
                                  ID2 |= payload[3];

                                  TYPE |= payload[8];
                                  TYPE <<= 4;
                                  TYPE |= payload[9];

                                  DATA0 |= payload[10];
                                  DATA0 <<= 4;
                                  DATA0 |= payload[11];

                                  DATA1 |= payload[12];
                                  DATA1 <<= 4;
                                  DATA1 |= payload[13];

                                  CRC |= payload[14];
                                  CRC <<= 4;
                                  CRC |= payload[15];

                                  nCRC |= payload[16];
                                  nCRC <<= 4;
                                  nCRC |= payload[17];

                                 CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, ID2, TYPE, DATA0, DATA1, CRC, nCRC);

                                  DATA_FULL |= DATA0;
                                  DATA_FULL <<=8;
                                  DATA_FULL |= DATA1;

                                  ID_FULL |= ID0;
                                  ID_FULL <<=8;
                                  ID_FULL |= ID1;
                                  ID_FULL <<=8;
                                  ID_FULL |= ID2;


                                  if(CRC_OK_NOK == 1)
                                  {
                                  switch (TYPE)
                                  {
                                        case 32: //20, CHECKED: TC77 OR MCP9808
                                              DATA_FULL <<= 3;
                                              degC = DATA_FULL;
                                              degC /= 100;
                                              degC *= 0.09765625;
                                              break;

                                        case 0x48: //30, NOT CHECKED: T6613
                                              // not used
                                              break;
                                        case 64: //40, CHECKED: SHT10



                                            temp_id = 0;
                                            temp_id = ID_FULL;
                                            temp_id <<= 31;
                                            temp_id >>= 31;

                                            // IF LAATSTE BIT ID 1 IS DAN IS HET HUM
                                            if(temp_id == 1)
                                            {
                                                //IF HUM:
                                                float tempHum = DATA_FULL * DATA_FULL;
                                                tempHum *=1.5955E-6;
                                                hum = DATA_FULL;
                                                hum *= 0.0367;
                                                hum -= 2.0468;
                                                hum -= tempHum;

                                            }
                                            else{
                                              degC = DATA_FULL;
                                              degC *= 0.01;
                                              degC -= 39.6;

                                            }

                                              break;

                                        case 80: //50, NOT CHECKED
                                              //HDS1080

              //                                //IF HUM:
              //                                hum = DATA;
              //                                hum *= 0.152587890625;
              //
              //                                // IF TEMP:
              //                                degC = DATA;
              //                                degC *= 0.25177001953125;
              //                                degC -= 4000;

                                              break;

                                        case 224:  //E0 CHECKED: temp pt100

                                              degC = DATA_FULL;
                                              degC /= 100;
                                              degC *= 0.390625;


                                              break;

                                        case 240: //F0, CHECKED bat volt

                                              vbat = 2097.152;
                                              vbat /= DATA_FULL;

                                              break;

                                        default:
                                              // UNKNOWN
                                              DataCalc = 69420;

                                              break;

                                  }
                             }



                      }

count++;

}


/*
 * Application LED pin configuration table:
 *   - All LEDs board LEDs are off.
 */
PIN_Config pinTable[] =
{
    Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
	PIN_TERMINATE
};

/***** Function definitions *****/

void *mainThread(void *arg0)
{
    GPIO_init();
    GPIO_setConfig(Board_GPIO_RLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW );





    RF_Params rfParams;
    RF_Params_init(&rfParams);



    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);
    }

    /* Set the Data Entity queue for received data */
    RF_cmdPropRx.pQueue = &dataQueue;
    /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
    /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.maxPktLen = MAX_LENGTH;
    RF_cmdPropRx.pktConf.bRepeatOk = 1;
    RF_cmdPropRx.pktConf.bRepeatNok = 1;

    /* Request access to the radio */
#if defined(DeviceFamily_CC26X0R2)
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
#else
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
#endif// DeviceFamily_CC26X0R2

    /* 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_cmdPropRx,
                                               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, Board_PIN_LED2,
//                           !PIN_getOutputValue(Board_PIN_LED2));

        /* Get current unhandled data entry */
        currentDataEntry = RFQueue_getDataEntry();

        /* Handle the packet data, located at &currentDataEntry->data:
         * - Length is the first byte with the current configuration
         * - Data starts from the second byte */
        packetLength      = 19;
        packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);

        /* Copy the payload + the status byte to the packet variable */
        memcpy(packet, packetDataPointer, (packetLength + 1));

        RFQueue_nextEntry();
        toggle();

    }
}

But when I combine the two codes like in the code block below, it gets stuck. Using breakpoints I found it gets stuck somewhere in f_open.  (As you can see I defined some dummy data to save to the SD card for test purposes.)

/*
 * Copyright (c) 2019, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>


/* TI Drivers */
#include <time.h>
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/gpio.h>
/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)

/* Board Header files */
#include "Board.h"

/* Application Header files */
#include "RFQueue.h"
#include "smartrf_settings/smartrf_settings.h"

/* SD driver headers */
#include <ti/drivers/SD.h>
#include <ti/display/Display.h>
#include <third_party/fatfs/ff.h>
#include <third_party/fatfs/diskio.h>
#include <third_party/fatfs/ffcio.h>
#include <third_party/fatfs/ffconf.h>
#include "ti/drivers/SDFatFS.h"

/* Custom header files*/
#include <Manchester.h>
#include <CRC8.h>




/***** Defines *****/

/* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE 9  /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH             19 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                   * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                   * Max 30 payload bytes
                                   * 1 status byte (RF_cmdPropRx.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 uint8_t packetLength;
static uint8_t* packetDataPointer;
uint8_t payload[19];


int32_t fatfs_getFatTime(void){
time_t seconds;
uint32_t fatTime;
struct tm *pTime;

        /*
         *  TI time() returns seconds elapsed since 1900, while other tools
         *  return seconds from 1970.  However, both TI and GNU localtime()
         *  sets tm tm_year to number of years since 1900.
         */
        seconds = time(NULL);

        pTime = localtime(&seconds);

        /*
         *  localtime() sets pTime->tm_year to number of years
         *  since 1900, so subtract 80 from tm_year to get FAT time
         *  offset from 1980.
         */
        fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
            ((uint32_t)(pTime->tm_mon) << 21) |
            ((uint32_t)(pTime->tm_mday) << 16) |
            ((uint32_t)(pTime->tm_hour) << 11) |
            ((uint32_t)(pTime->tm_min) << 5) |
            ((uint32_t)(pTime->tm_sec) >> 1);

        return ((int32_t)fatTime);
}


SDFatFS_Object myObj;
SDFatFS_Config SDFatFS_config[] =
     {
         { &myObj },
         NULL
     };
uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;


void createTxtFileOnSD(uint32_t BASEID, float data, uint32_t IDSENSOR, uint8_t time, uint8_t date){
    FIL fsrc;  /* File objects */
    FRESULT fr;          /* FatFs function common result code */
    UINT bw;         /* File read/write count */




    SDFatFS_Handle sd_handle;
    SDFatFS_init();

    sd_handle = SDFatFS_open(Board_SD0,0);
       if (sd_handle == NULL)
       {
           while(1);

       }

       uint32_t TXTID = BASEID;
       int TXTFILENAME;
       char TXTNAME[15];
       TXTFILENAME = snprintf(TXTNAME, 15, "%d.txt", TXTID);

       fr = f_open(&fsrc, TXTNAME, FA_OPEN_EXISTING | FA_WRITE);
           switch (fr)
           {
               case FR_NO_FILE:
               fr = f_open(&fsrc, TXTNAME, FA_CREATE_NEW | FA_WRITE);

               case FR_OK:

                   f_open(&fsrc, TXTNAME, FA_OPEN_APPEND | FA_WRITE);
               default:
               break;
           }

           if(fr != 0)
           {
               while(1);
           }

           char buffer[100];
           char buffer2[100];
           int cx;
           int cx2;
           int counter = 0;

           while(counter <1)
           {
               cx = snprintf (buffer, sizeof(buffer), "\{\"%d\":\[", BASEID);
               cx2 = snprintf (buffer2, sizeof(buffer2),  "\"ID\":\"%d\"\,    \"Data\":%0.2f\," "\"time\":\"%d\"\, \"date\":\"%d\"\}\]\}\r\n", IDSENSOR, data, time, date);

               fr = f_write(&fsrc, buffer, cx, &bw);
               fr = f_write(&fsrc, buffer2, cx2, &bw);
               CPUdelay(8000 * (100));
               counter++;

               if(fr != 0)
               {
                   while(1);
               }

                            /* Try to sync */
               fr = f_sync(&fsrc);
               if(fr != 0){
                   while(1);
               }



           }
           /* Close open files */
fr =     f_close(&fsrc);


}


static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
uint16_t count = 0;
void toggle();
void toggle(){


    uint32_t BASEID = 113400;
    uint32_t SENSID = 123;
    float temperature = 34.9;
    uint8_t time = 13;
    uint8_t date = 15;
    createTxtFileOnSD(BASEID, temperature, SENSID, time, date);


    uint8_t CRC_OK_NOK = 0;
        float DataCalc = 0;
        float degC = 0;
        float hum = 0;
        float vbat = 0;

        uint8_t LENGTH =0;
        uint8_t ID0=0;
        uint8_t ID1=0;
        uint8_t ID2=0;
        uint32_t ID_FULL = 0;
        uint8_t TYPE=0;
        uint8_t DATA0=0;
        uint8_t DATA1=0;
        uint16_t DATA_FULL = 0;
        uint8_t CRC=0;
        uint8_t nCRC=0;
        uint32_t temp_id = 0;
        uint16_t temp_id5 = 0;
        int c = 0;
            for (c = 0; c < 19; c++)
            {
                  payload[c] = manDecode(packet[c]);

            }
            LENGTH |= payload[0];
                 LENGTH <<= 4;
                 LENGTH |= payload[1];

                 GPIO_toggle(Board_GPIO_RLED);

                 if(LENGTH == 5){

                                    ID0 |= payload[4];
                                    ID0 <<= 4;
                                    ID0 |= payload[5];

                                    ID1 |= payload[2];
                                    ID1 <<= 4;
                                    ID1 |= payload[3];

                                    DATA0 |= payload[6];
                                    DATA0 <<= 4;
                                    DATA0 |= payload[7];

                                    DATA1 |= payload[8];
                                    DATA1 <<= 4;
                                    DATA1 |= payload[9];


                                    CRC |= payload[10];
                                    CRC <<= 4;
                                    CRC |= payload[11];

                                    CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0);

                                    DATA_FULL |= DATA0;
                                    DATA_FULL <<=8;
                                    DATA_FULL |= DATA1;
                                    DataCalc = DATA_FULL;

                                    ID_FULL |= ID0;
                                    ID_FULL <<=8;
                                    ID_FULL |= ID1;

                                    if(CRC_OK_NOK == 1)
                                    {
                                    DataCalc /= 100;
                                    DataCalc *=0.78125;

                                    // IF LAATSTE BIT ID 1 IS DAN IS HET TEMP
                                    temp_id5 = ID_FULL;
                                    temp_id5 <<= 15;
                                    temp_id5 >>= 15;
                                    if(temp_id5 == 1)
                                    {
                                    degC = DataCalc;

                                    }
                                    else
                                    {
                                        hum = DataCalc;

                                    }

                               }

                       }

                 if(LENGTH == 7)
                         {

                                  ID0 |= payload[6];
                                  ID0 <<= 4;
                                  ID0 |= payload[7];

                                  ID1 |= payload[4];
                                  ID1 <<= 4;
                                  ID1 |= payload[5];

                                  ID2 |= payload[2];
                                  ID2 <<= 4;
                                  ID2 |= payload[3];

                                  TYPE |= payload[8];
                                  TYPE <<= 4;
                                  TYPE |= payload[9];

                                  DATA0 |= payload[10];
                                  DATA0 <<= 4;
                                  DATA0 |= payload[11];

                                  DATA1 |= payload[12];
                                  DATA1 <<= 4;
                                  DATA1 |= payload[13];

                                  CRC |= payload[14];
                                  CRC <<= 4;
                                  CRC |= payload[15];

                                  nCRC |= payload[16];
                                  nCRC <<= 4;
                                  nCRC |= payload[17];

                                 CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, ID2, TYPE, DATA0, DATA1, CRC, nCRC);

                                  DATA_FULL |= DATA0;
                                  DATA_FULL <<=8;
                                  DATA_FULL |= DATA1;

                                  ID_FULL |= ID0;
                                  ID_FULL <<=8;
                                  ID_FULL |= ID1;
                                  ID_FULL <<=8;
                                  ID_FULL |= ID2;


                                  if(CRC_OK_NOK == 1)
                                  {
                                  switch (TYPE)
                                  {
                                        case 32: //20, CHECKED: TC77 OR MCP9808
                                              DATA_FULL <<= 3;
                                              degC = DATA_FULL;
                                              degC /= 100;
                                              degC *= 0.09765625;
                                              break;

                                        case 0x48: //30, NOT CHECKED: T6613
                                              // not used
                                              break;
                                        case 64: //40, CHECKED: SHT10



                                            temp_id = 0;
                                            temp_id = ID_FULL;
                                            temp_id <<= 31;
                                            temp_id >>= 31;

                                            // IF LAATSTE BIT ID 1 IS DAN IS HET HUM
                                            if(temp_id == 1)
                                            {
                                                //IF HUM:
                                                float tempHum = DATA_FULL * DATA_FULL;
                                                tempHum *=1.5955E-6;
                                                hum = DATA_FULL;
                                                hum *= 0.0367;
                                                hum -= 2.0468;
                                                hum -= tempHum;

                                            }
                                            else{
                                              degC = DATA_FULL;
                                              degC *= 0.01;
                                              degC -= 39.6;

                                            }

                                              break;

                                        case 80: //50, NOT CHECKED
                                              //HDS1080

              //                                //IF HUM:
              //                                hum = DATA;
              //                                hum *= 0.152587890625;
              //
              //                                // IF TEMP:
              //                                degC = DATA;
              //                                degC *= 0.25177001953125;
              //                                degC -= 4000;

                                              break;

                                        case 224:  //E0 CHECKED: temp pt100

                                              degC = DATA_FULL;
                                              degC /= 100;
                                              degC *= 0.390625;


                                              break;

                                        case 240: //F0, CHECKED bat volt

                                              vbat = 2097.152;
                                              vbat /= DATA_FULL;

                                              break;

                                        default:
                                              // UNKNOWN
                                              DataCalc = 69420;

                                              break;

                                  }
                             }



                      }

count++;

}


/*
 * Application LED pin configuration table:
 *   - All LEDs board LEDs are off.
 */
PIN_Config pinTable[] =
{
    Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
	PIN_TERMINATE
};

/***** Function definitions *****/

void *mainThread(void *arg0)
{
    GPIO_init();
    GPIO_setConfig(Board_GPIO_RLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW );





    RF_Params rfParams;
    RF_Params_init(&rfParams);



    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);
    }

    /* Set the Data Entity queue for received data */
    RF_cmdPropRx.pQueue = &dataQueue;
    /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
    /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.maxPktLen = MAX_LENGTH;
    RF_cmdPropRx.pktConf.bRepeatOk = 1;
    RF_cmdPropRx.pktConf.bRepeatNok = 1;

    /* Request access to the radio */
#if defined(DeviceFamily_CC26X0R2)
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
#else
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
#endif// DeviceFamily_CC26X0R2

    /* 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_cmdPropRx,
                                               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, Board_PIN_LED2,
//                           !PIN_getOutputValue(Board_PIN_LED2));

        /* Get current unhandled data entry */
        currentDataEntry = RFQueue_getDataEntry();

        /* Handle the packet data, located at &currentDataEntry->data:
         * - Length is the first byte with the current configuration
         * - Data starts from the second byte */
        packetLength      = 19;
        packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);

        /* Copy the payload + the status byte to the packet variable */
        memcpy(packet, packetDataPointer, (packetLength + 1));

        RFQueue_nextEntry();
        toggle();

    }
}

I have stepped all the way into f_open and followed the following path:

f_open goes to find_volume, to disk_initialize, to SDFatFS_diskInitialize, to SD_initialize, to SDSPI_initialize, to SemaphoreP_pend(object->lockSem, SemaphoreP_WAIT_FOREVER) and that's as far is I can go.

It gets stuck and it has to do something with this SemaphoreP_pend in the SDSPI_initialize function in the SDSPI.c file, I just don't know what.

I have no idea why these two code blocks won't combine, it makes NO sense to me. Can someone please help make this work? 

Kind regards,

Mirte H 

  • Could you please take a look at your thread stack size, and try increasing it? It might be running out of memory.

  • Hello Arthur,

    I just looked at the stack usage for my project and indeed found that my WriteToSD function is taking a whole lot of stack size because of two snprintf functions i'm using. I will definitely look in to finding a more efficient way to do that. 

    Is right clicking on callback, clicking 'annotate' and changing the stack size the right way to do increase my stack size?

    Kind regards,

    Mirte H

  • The preferred way to do that would be to edit CC1310_LAUNCHXL_NoRTOS.cmd, and tweak the following settings:

    • --stack_size
    • --heap_size

    However, you could also try to refactor your code so that you do not handle the SD card operations inside of the callback.

    BR,

    Arthur

  • Hi Arthur,

    I edited the code back to a simple f_open and f_close, which halved the stack size:

    I then edited the stack size and heap size, but even when making them this big:

    --stack_size=10240

    --heap_size=4352

    I still got the same issue. I don't think the general stack and/or heap size are the problem. 

    Even after I up the stack and heap size, could the issue still be that my callback is too big?

    I don't know how/where else to execute the toggle function. It has to execute directly after receiving an RF packet. I know using a semaphore could work, but I don't want to use RTOS.

    Here's my code again, just in case:

    /*
     * Copyright (c) 2019, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    
    /* TI Drivers */
    #include <time.h>
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/gpio.h>
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* Board Header files */
    #include "Board.h"
    
    /* Application Header files */
    #include "RFQueue.h"
    #include "smartrf_settings/smartrf_settings.h"
    
    /* SD driver headers */
    #include <ti/drivers/SD.h>
    #include <ti/display/Display.h>
    #include <third_party/fatfs/ff.h>
    #include <third_party/fatfs/diskio.h>
    #include <third_party/fatfs/ffcio.h>
    #include <third_party/fatfs/ffconf.h>
    #include "ti/drivers/SDFatFS.h"
    
    /* Custom header files*/
    #include <Manchester.h>
    #include <CRC8.h>
    
    
    
    
    /***** Defines *****/
    
    /* Packet RX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 9  /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             19 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                       * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                       * Max 30 payload bytes
                                       * 1 status byte (RF_cmdPropRx.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 uint8_t packetLength;
    static uint8_t* packetDataPointer;
    uint8_t payload[19];
    
    int32_t fatfs_getFatTime(void){
    time_t seconds;
    uint32_t fatTime;
    struct tm *pTime;
    
            /*
             *  TI time() returns seconds elapsed since 1900, while other tools
             *  return seconds from 1970.  However, both TI and GNU localtime()
             *  sets tm tm_year to number of years since 1900.
             */
            seconds = time(NULL);
    
            pTime = localtime(&seconds);
    
            /*
             *  localtime() sets pTime->tm_year to number of years
             *  since 1900, so subtract 80 from tm_year to get FAT time
             *  offset from 1980.
             */
            fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
                ((uint32_t)(pTime->tm_mon) << 21) |
                ((uint32_t)(pTime->tm_mday) << 16) |
                ((uint32_t)(pTime->tm_hour) << 11) |
                ((uint32_t)(pTime->tm_min) << 5) |
                ((uint32_t)(pTime->tm_sec) >> 1);
    
            return ((int32_t)fatTime);
    }
    
    
    SDFatFS_Object myObj;
    SDFatFS_Config SDFatFS_config[] =
         {
             { &myObj },
             NULL
         };
    uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;
    
    
    
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
    uint16_t count = 0;
    void toggle();
    void toggle(){
    
          FIL fsrc;  /* File objects */
          FRESULT fr;          /* FatFs function common result code */
          UINT bw;         /* File read/write count */
    
    
    
    
          SDFatFS_Handle sd_handle;
          SDFatFS_init();
    
          sd_handle = SDFatFS_open(Board_SD0,0);
             if (sd_handle == NULL)
             {
                 while(1);
             }
    
             fr = f_open(&fsrc, "123.txt", FA_OPEN_EXISTING | FA_WRITE);
    
                     switch (fr)
                     {
                         case FR_NO_FILE:
                         fr = f_open(&fsrc, "123.txt", FA_CREATE_NEW | FA_WRITE);
    
                         case FR_OK:
    
                             f_open(&fsrc, "123.txt", FA_OPEN_APPEND | FA_WRITE);
                         default:
                         break;
                     }
    
                     if(fr != 0)
                     {
                         while(1);
                     }
    
        uint8_t CRC_OK_NOK = 0;
            float DataCalc = 0;
            float degC = 0;
            float hum = 0;
            float vbat = 0;
    
            uint8_t LENGTH =0;
            uint8_t ID0=0;
            uint8_t ID1=0;
            uint8_t ID2=0;
            uint32_t ID_FULL = 0;
            uint8_t TYPE=0;
            uint8_t DATA0=0;
            uint8_t DATA1=0;
            uint16_t DATA_FULL = 0;
            uint8_t CRC=0;
            uint8_t nCRC=0;
            uint32_t temp_id = 0;
            uint16_t temp_id5 = 0;
            int c = 0;
                for (c = 0; c < 19; c++)
                {
                      payload[c] = manDecode(packet[c]);
    
                }
                LENGTH |= payload[0];
                     LENGTH <<= 4;
                     LENGTH |= payload[1];
    
                     GPIO_toggle(Board_GPIO_RLED);
    
                     if(LENGTH == 5){
    
                                        ID0 |= payload[4];
                                        ID0 <<= 4;
                                        ID0 |= payload[5];
    
                                        ID1 |= payload[2];
                                        ID1 <<= 4;
                                        ID1 |= payload[3];
    
                                        DATA0 |= payload[6];
                                        DATA0 <<= 4;
                                        DATA0 |= payload[7];
    
                                        DATA1 |= payload[8];
                                        DATA1 <<= 4;
                                        DATA1 |= payload[9];
    
    
                                        CRC |= payload[10];
                                        CRC <<= 4;
                                        CRC |= payload[11];
    
                                        CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0);
    
                                        DATA_FULL |= DATA0;
                                        DATA_FULL <<=8;
                                        DATA_FULL |= DATA1;
                                        DataCalc = DATA_FULL;
    
                                        ID_FULL |= ID0;
                                        ID_FULL <<=8;
                                        ID_FULL |= ID1;
    
                                        if(CRC_OK_NOK == 1)
                                        {
                                        DataCalc /= 100;
                                        DataCalc *=0.78125;
    
                                        // IF LAATSTE BIT ID 1 IS DAN IS HET TEMP
                                        temp_id5 = ID_FULL;
                                        temp_id5 <<= 15;
                                        temp_id5 >>= 15;
                                        if(temp_id5 == 1)
                                        {
                                        degC = DataCalc;
    
                                        }
                                        else
                                        {
                                            hum = DataCalc;
    
                                        }
    
                                   }
    
                           }
    
                     if(LENGTH == 7)
                             {
    
                                      ID0 |= payload[6];
                                      ID0 <<= 4;
                                      ID0 |= payload[7];
    
                                      ID1 |= payload[4];
                                      ID1 <<= 4;
                                      ID1 |= payload[5];
    
                                      ID2 |= payload[2];
                                      ID2 <<= 4;
                                      ID2 |= payload[3];
    
                                      TYPE |= payload[8];
                                      TYPE <<= 4;
                                      TYPE |= payload[9];
    
                                      DATA0 |= payload[10];
                                      DATA0 <<= 4;
                                      DATA0 |= payload[11];
    
                                      DATA1 |= payload[12];
                                      DATA1 <<= 4;
                                      DATA1 |= payload[13];
    
                                      CRC |= payload[14];
                                      CRC <<= 4;
                                      CRC |= payload[15];
    
                                      nCRC |= payload[16];
                                      nCRC <<= 4;
                                      nCRC |= payload[17];
    
                                     CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, ID2, TYPE, DATA0, DATA1, CRC, nCRC);
    
                                      DATA_FULL |= DATA0;
                                      DATA_FULL <<=8;
                                      DATA_FULL |= DATA1;
    
                                      ID_FULL |= ID0;
                                      ID_FULL <<=8;
                                      ID_FULL |= ID1;
                                      ID_FULL <<=8;
                                      ID_FULL |= ID2;
    
    
                                      if(CRC_OK_NOK == 1)
                                      {
                                      switch (TYPE)
                                      {
                                            case 32: //20, CHECKED: TC77 OR MCP9808
                                                  DATA_FULL <<= 3;
                                                  degC = DATA_FULL;
                                                  degC /= 100;
                                                  degC *= 0.09765625;
                                                  break;
    
                                            case 0x48: //30, NOT CHECKED: T6613
                                                  // not used
                                                  break;
                                            case 64: //40, CHECKED: SHT10
    
    
    
                                                temp_id = 0;
                                                temp_id = ID_FULL;
                                                temp_id <<= 31;
                                                temp_id >>= 31;
    
                                                // IF LAATSTE BIT ID 1 IS DAN IS HET HUM
                                                if(temp_id == 1)
                                                {
                                                    //IF HUM:
                                                    float tempHum = DATA_FULL * DATA_FULL;
                                                    tempHum *=1.5955E-6;
                                                    hum = DATA_FULL;
                                                    hum *= 0.0367;
                                                    hum -= 2.0468;
                                                    hum -= tempHum;
    
                                                }
                                                else{
                                                  degC = DATA_FULL;
                                                  degC *= 0.01;
                                                  degC -= 39.6;
    
                                                }
    
                                                  break;
    
                                            case 80: //50, NOT CHECKED
                                                  //HDS1080
    
                  //                                //IF HUM:
                  //                                hum = DATA;
                  //                                hum *= 0.152587890625;
                  //
                  //                                // IF TEMP:
                  //                                degC = DATA;
                  //                                degC *= 0.25177001953125;
                  //                                degC -= 4000;
    
                                                  break;
    
                                            case 224:  //E0 CHECKED: temp pt100
    
                                                  degC = DATA_FULL;
                                                  degC /= 100;
                                                  degC *= 0.390625;
    
    
                                                  break;
    
                                            case 240: //F0, CHECKED bat volt
    
                                                  vbat = 2097.152;
                                                  vbat /= DATA_FULL;
    
                                                  break;
    
                                            default:
                                                  // UNKNOWN
                                                  DataCalc = 69420;
    
                                                  break;
    
                                      }
                                 }
    
    
    
                          }
    
    count++;
    
    }
    
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
        Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    	PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        GPIO_init();
        GPIO_setConfig(Board_GPIO_RLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW );
    
    
    
    
    
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
    
    
        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);
        }
    
        /* Set the Data Entity queue for received data */
        RF_cmdPropRx.pQueue = &dataQueue;
        /* Discard ignored packets from Rx queue */
        RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdPropRx.maxPktLen = MAX_LENGTH;
        RF_cmdPropRx.pktConf.bRepeatOk = 1;
        RF_cmdPropRx.pktConf.bRepeatNok = 1;
    
        /* Request access to the radio */
    #if defined(DeviceFamily_CC26X0R2)
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2
    
        /* 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_cmdPropRx,
                                                   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, Board_PIN_LED2,
    //                           !PIN_getOutputValue(Board_PIN_LED2));
    
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            /* Handle the packet data, located at &currentDataEntry->data:
             * - Length is the first byte with the current configuration
             * - Data starts from the second byte */
            packetLength      = 19;
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
    
            /* Copy the payload + the status byte to the packet variable */
            memcpy(packet, packetDataPointer, (packetLength + 1));
    
            RFQueue_nextEntry();
            toggle();
    
        }
    }
    

    Kind regards,

    Mirte H

  • Hi,

    Did you add any #defines or files to your project? Also, what base project did you use, is it rfPacketRx?

    What SDK version are you using?

    Kind regards,

    Arthur

  • Hi Arthur,

    1. If I'm correct I'm using the following SDK: simplelink_CC13x0_sdk_4_20_01_03. Just to be sure I added a screenshot:

    2. the base project i'm using is rfPacketRX_noRTOS, with custom frequency and packet settings. 

    3. I did not add any defines.

    4. I added my own header files:

    #include <Manchester.h>
    #include <CRC8.h>

    In the code I posted before, the functions belonging to these headers are used in line 228:  payload[c] = manDecode(packet[c]); 
    and in line 260: CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0);

    as you can see, both of these are called after the f_open call.

    I used these files in my basic rfPacketRX_NORTOS code (just receiving and decoding packets, without the SD card codes) and they work perfectly fine.

    Thanks again, I have a lot depending on this code so your time is really appreciated Slight smile

    Kind regards,

    Mirte H

  • Hi Arthur,

    to add something else:

    I originally made this code in TIRTOS. But I only made it in TIRTOS because i needed a semaphore to get my decoding out of the callback, just like you said. Then when I went to add the SD card functionality it didn't work in TIRTOS, and I thought it was because my semaphores were messing things up. I don't know a lot about RTOS so I decided to try it in noRTOS and just put the toggle function in the callback. But then the SD card also didn't work and I created this post.

    Now I'm trying in TIRTOS again, because I wanted to see if it would clear things up perhaps.

    In TIRTOS the code also gets stuck during F_open. This time though, i can see exactly where the program loops using the dissasembler, though I don't know what it means. This is exactly what I see:

    What it opens when I suspend the debugging session:

    Where the dissasembler loops:

    When pressing the resume and step over/step into button it just switches between 0x1001bbd2 and 0x1001bbd4.

    I have NO idea what any of this means, but now that we know exactly where it halts during TIRTOS perhaps there's more to go on?

    If this made things even more confusing feel free to ignore this comment and we'll keep going with figuring it out in NORTOS Slight smile

    Here's the TIRTOS code just in case:

    /***** Includes *****/
    /* Standard C Libraries */
    
    #include<stdio.h>
    #include <math.h>
    #include <stddef.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #include <String.h>
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/SD.h>
    #include <ti/display/Display.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* FatFS SD card libraries*/
    #include <third_party/fatfs/ff.h>
    #include <third_party/fatfs/diskio.h>
    #include <third_party/fatfs/ffcio.h>
    #include <third_party/fatfs/ffconf.h>
    #include "ti/drivers/SDFatFS.h"
    #include <ti/drivers/SD.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    /* Application Header files */
    #include "RFQueue.h"
    #include "smartrf_settings/smartrf_settings.h"
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/drivers/UART.h>
    
    /* Custom header files */
    #include <CRC8.h>
    #include <Manchester.h>
    
    
    
    
    
    
    int32_t fatfs_getFatTime(void){
    time_t seconds;
    uint32_t fatTime;
    struct tm *pTime;
    
            /*
             *  TI time() returns seconds elapsed since 1900, while other tools
             *  return seconds from 1970.  However, both TI and GNU localtime()
             *  sets tm tm_year to number of years since 1900.
             */
            seconds = time(NULL);
    
            pTime = localtime(&seconds);
    
            /*
             *  localtime() sets pTime->tm_year to number of years
             *  since 1900, so subtract 80 from tm_year to get FAT time
             *  offset from 1980.
             */
            fatTime = ((uint32_t)(pTime->tm_year - 80) << 25) |
                ((uint32_t)(pTime->tm_mon) << 21) |
                ((uint32_t)(pTime->tm_mday) << 16) |
                ((uint32_t)(pTime->tm_hour) << 11) |
                ((uint32_t)(pTime->tm_min) << 5) |
                ((uint32_t)(pTime->tm_sec) >> 1);
    
            return ((int32_t)fatTime);
    }
    
    
    SDFatFS_Object myObj;
    SDFatFS_Config SDFatFS_config[] =
         {
             { &myObj },
             NULL
         };
    uint_least8_t SDFatFS_count = sizeof(SDFatFS_config) / sizeof(SDFatFS_config[0]) - 1;
    
    /*
    
    
    
    
    
    /***** Defines *****/
    
    /* Packet RX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 9  /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             19 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES       2  /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES     2  /* The Data Entries data field will contain:
                                       * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
                                       * Max 30 payload bytes
                                       * 1 status byte (RF_cmdPropRx.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 uint8_t packetLength;
    static uint8_t* packetDataPointer;
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
    
    
    /* Custom raw and decoded payloads */
    uint8_t payload[19];
    uint8_t decoded[MAX_LENGTH];
    /* RX Semaphore */
    static Semaphore_Struct rxSemaphore;
    static Semaphore_Handle rxSemaphoreHandle;
    
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    PIN_Config pinTable[] =
    {
     Board_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);
    
        /* Initialize RX semaphore */
        Semaphore_construct(&rxSemaphore, 0, NULL);
        rxSemaphoreHandle = Semaphore_handle(&rxSemaphore);
    
        Display_Params params;
        Display_Params_init(&params);
        params.lineClearMode = DISPLAY_CLEAR_BOTH;
        Display_Handle uartDisplayHandle = Display_open(Display_Type_UART, &params);
    
        /* 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_cmdPropRx.pQueue = &dataQueue;
        /* Discard ignored packets from Rx queue */
        RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdPropRx.maxPktLen = MAX_LENGTH;
        RF_cmdPropRx.pktConf.bRepeatOk = 1;
        RF_cmdPropRx.pktConf.bRepeatNok = 1;
    
        /* Request access to the radio */
    #if defined(DeviceFamily_CC26X0R2)
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
        /* Enter RX mode and stay forever in RX */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
    
    
    
    
        while(1)
        {
    
            Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
    
    
            FIL fsrc;  /* File objects */
            FRESULT fr;          /* FatFs function common result code */
            UINT bw;         /* File read/write count */
    
    
            SDFatFS_Handle sd_handle;
            SDFatFS_init();
    
            /* INIT spi with SD card libs */
            sd_handle = SDFatFS_open(Board_SD0,0);
            if (sd_handle == NULL)
            {
                while(1);
            }
    
    
            /*OPEN file on sd card*/
            fr = f_open(&fsrc, "test.txt", FA_OPEN_EXISTING | FA_WRITE);
            if(fr!=0)
            {
                while(1);
            }
    
            switch (fr)
            {
                case FR_NO_FILE:
                    fr = f_open(&fsrc, "test.txt", FA_CREATE_NEW | FA_WRITE);
    
                default:
                    break;
            }
    
    
            /* Close open files */
            fr =     f_close(&fsrc);
    
    
            uint8_t CRC_OK_NOK = 0;
            float DataCalc = 0;
            float degC = 0;
            float hum = 0;
            float vbat = 0;
    
            uint8_t LENGTH =0;
            uint8_t ID0=0;
            uint8_t ID1=0;
            uint8_t ID2=0;
            uint32_t ID_FULL = 0;
            uint8_t TYPE=0;
            uint8_t DATA0=0;
            uint8_t DATA1=0;
            uint16_t DATA_FULL = 0;
            uint8_t CRC=0;
            uint8_t nCRC=0;
            uint32_t temp_id = 0;
            uint16_t temp_id5 = 0;
    
            int c = 0;
    
            for (c = 0; c < 19; c++)
            {
                  payload[c] = manDecode(packet[c]);
    
            }
    
            LENGTH |= payload[0];
            LENGTH <<= 4;
            LENGTH |= payload[1];
    
           if(LENGTH == 5){
    
                        ID0 |= payload[4];
                        ID0 <<= 4;
                        ID0 |= payload[5];
    
                        ID1 |= payload[2];
                        ID1 <<= 4;
                        ID1 |= payload[3];
    
                        DATA0 |= payload[6];
                        DATA0 <<= 4;
                        DATA0 |= payload[7];
    
                        DATA1 |= payload[8];
                        DATA1 <<= 4;
                        DATA1 |= payload[9];
    
    
                        CRC |= payload[10];
                        CRC <<= 4;
                        CRC |= payload[11];
    
                        CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, 0, 0, DATA0, DATA1, CRC, 0);
    
                        DATA_FULL |= DATA0;
                        DATA_FULL <<=8;
                        DATA_FULL |= DATA1;
                        DataCalc = DATA_FULL;
    
                        ID_FULL |= ID0;
                        ID_FULL <<=8;
                        ID_FULL |= ID1;
    
                        if(CRC_OK_NOK == 1)
                        {
                            DataCalc /= 100;
                            DataCalc *=0.78125;
    
                            // IF LAATSTE BIT ID 1 IS DAN IS HET TEMP
                            temp_id5 = ID_FULL;
                            temp_id5 <<= 15;
                            temp_id5 >>= 15;
                                if(temp_id5 == 1)
                                {
                                    degC = DataCalc;
    
                                }
                                else
                                {
                                    hum = DataCalc;
    
                                }
    
                   }
    
           }
               if(LENGTH == 7)
               {
    
                        ID0 |= payload[6];
                        ID0 <<= 4;
                        ID0 |= payload[7];
    
                        ID1 |= payload[4];
                        ID1 <<= 4;
                        ID1 |= payload[5];
    
                        ID2 |= payload[2];
                        ID2 <<= 4;
                        ID2 |= payload[3];
    
                        TYPE |= payload[8];
                        TYPE <<= 4;
                        TYPE |= payload[9];
    
                        DATA0 |= payload[10];
                        DATA0 <<= 4;
                        DATA0 |= payload[11];
    
                        DATA1 |= payload[12];
                        DATA1 <<= 4;
                        DATA1 |= payload[13];
    
                        CRC |= payload[14];
                        CRC <<= 4;
                        CRC |= payload[15];
    
                        nCRC |= payload[16];
                        nCRC <<= 4;
                        nCRC |= payload[17];
    
                        CRC_OK_NOK = doCrc(LENGTH, ID0, ID1, ID2, TYPE, DATA0, DATA1, CRC, nCRC);
    
                        DATA_FULL |= DATA0;
                        DATA_FULL <<=8;
                        DATA_FULL |= DATA1;
    
                        ID_FULL |= ID0;
                        ID_FULL <<=8;
                        ID_FULL |= ID1;
                        ID_FULL <<=8;
                        ID_FULL |= ID2;
    
    
                        if(CRC_OK_NOK == 1)
                        {
                            switch (TYPE)
                            {
                            case 32: //20, CHECKED: TC77 OR MCP9808
                                    DATA_FULL <<= 3;
                                    degC = DATA_FULL;
                                    degC /= 100;
                                    degC *= 0.09765625;
                                    break;
    
                            case 0x48: //30, NOT CHECKED: T6613
                                    // not used
                                break;
                            case 64: //40, CHECKED: SHT10
    
                                  temp_id = 0;
                                  temp_id = ID_FULL;
                                  temp_id <<= 31;
                                  temp_id >>= 31;
    
                                  // IF LAATSTE BIT ID 1 IS DAN IS HET HUM
                                  if(temp_id == 1)
                                      {
                                      //IF HUM:
                                          float tempHum = DATA_FULL * DATA_FULL;
                                          tempHum *=1.5955E-6;
                                          hum = DATA_FULL;
                                          hum *= 0.0367;
                                          hum -= 2.0468;
                                          hum -= tempHum;
    
                                      }
                                      else
                                      {
                                          degC = DATA_FULL;
                                          degC *= 0.01;
                                          degC -= 39.6;
    
                                      }
    
                                    break;
    
                              case 80: //50, NOT CHECKED
                                    //HDS1080
    
    //                                //IF HUM:
    //                                hum = DATA;
    //                                hum *= 0.152587890625;
    //
    //                                // IF TEMP:
    //                                degC = DATA;
    //                                degC *= 0.25177001953125;
    //                                degC -= 4000;
    
                                    break;
    
                              case 224:  //E0 CHECKED: temp pt100
    
                                    degC = DATA_FULL;
                                    degC /= 100;
                                    degC *= 0.390625;
    
    
                                    break;
    
                              case 240: //F0, CHECKED bat volt
    
                                    vbat = 2097.152;
                                    vbat /= DATA_FULL;
    
                                    break;
    
                              default:
                                    // UNKNOWN
                                    DataCalc = 69420;
    
                                    break;
    
                        }
                   }
    
            }
    
     }
    }
    
    
    
    
    
    
    
    
    
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventRxEntryDone)
        {
            /* Toggle pin to indicate RX */
    //        PIN_setOutputValue(Board_PIN_RLED, CC1310_LAUNCHXL_PIN_RLED  ,
    //                           !PIN_getOutputValue(Board_PIN_RLED ));
    
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            /* Handle the packet data, located at &currentDataEntry->data:
             * - Length is the first byte with the current configuration
             * - Data starts from the second byte */
            packetLength      = 19;
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
    
            /* Copy the payload + the status byte to the packet variable */
            memcpy(packet, packetDataPointer, (packetLength + 1));
    
            RFQueue_nextEntry();
    
            Semaphore_post(rxSemaphoreHandle);
        }
    }
    

    Kind regards,

    Mirte H

  • Hi,

    Do you observe the same behavior on the CC1310 launchpad/LCD/SD Boosterpack?

  • The issue has been solved. The solution was to first initialize SDSPI and FatFS, and then turn on the radio. After that, everything worked perfectly. I have no explanation as to why it acts this way, but I am satisfied as my problem is solved.