Tool/software: Code Composer Studio
Hi
I want to dump IQ Samples as the introduction of CC13xx IQ Samples(swra571b) on LAUNCHXL-CC1352P1. I used the SDK_3_10_01_11, and I have modified the code (smartrf_setting.c and rfPacketRx.c ) as the report described. But the red led didn't flash and the callback function enter only twice when debugging. Here is my code, can you tell me where I was wrong or give me a correct one?
/* * Copyright (c) 2017, 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 <ti/drivers/rf/RF.h> #include <ti/drivers/PIN.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" /***** Defines *****/ /* Packet RX Configuration */ #define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */ #define MAX_LENGTH 30 /* 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) */ #define NUMBER_OF_SAMPLE_PAIRS 300 #define PARTIAL_RX_ENTRY_HEADER_SIZE 12 /***** 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 */ /* * 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 *****/ #if defined(__TI_COMPILER_VERSION__) #pragma DATA_ALIGN (rxDataEntryBuf1, 4); static uint8_t rxDataEntryBuf1[PARTIAL_RX_ENTRY_HEADER_SIZE + (NUMBER_OF_SAMPLE_PAIRS * 3)]; #pragma DATA_ALIGN (rxDataEntryBuf2, 4); static uint8_t rxDataEntryBuf2[PARTIAL_RX_ENTRY_HEADER_SIZE + (NUMBER_OF_SAMPLE_PAIRS * 3)]; #endif rfc_dataEntryPartial_t* partialReadEntry1 = (rfc_dataEntryPartial_t*)&rxDataEntryBuf1; rfc_dataEntryPartial_t* partialReadEntry2 = (rfc_dataEntryPartial_t*)&rxDataEntryBuf2; rfc_dataEntryPartial_t* currentReadEntry = (rfc_dataEntryPartial_t*)&rxDataEntryBuf1; void *mainThread(void *arg0) { RF_Params rfParams; RF_Params_init(&rfParams); partialReadEntry1->length = (NUMBER_OF_SAMPLE_PAIRS * 3) + 4; partialReadEntry1->config.type = DATA_ENTRY_TYPE_PARTIAL; partialReadEntry1->status = DATA_ENTRY_PENDING; partialReadEntry2->length = (NUMBER_OF_SAMPLE_PAIRS * 3) + 4; partialReadEntry2->config.type = DATA_ENTRY_TYPE_PARTIAL; partialReadEntry2->status = DATA_ENTRY_PENDING; partialReadEntry1->pNextEntry = (uint8_t*)partialReadEntry2; partialReadEntry2->pNextEntry = (uint8_t*)partialReadEntry1; dataQueue.pCurrEntry = (uint8_t*)partialReadEntry1; dataQueue.pLastEntry = NULL; /* 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); // } RF_cmdPropRx.pQueue = &dataQueue; /* 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; // /* Discard packets with CRC error from Rx queue */ // RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 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 */ 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_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone); switch(terminationReason) { case RF_EventLastCmdDone: // A stand-alone radio operation command or the last radio // operation command in a chain finished. break; case RF_EventCmdCancelled: // Command cancelled before it was started; it can be caused // by RF_cancelCmd() or RF_flushCmd(). break; case RF_EventCmdAborted: // Abrupt command termination caused by RF_cancelCmd() or // RF_flushCmd(). break; case RF_EventCmdStopped: // Graceful command termination caused by RF_cancelCmd() or // RF_flushCmd(). break; default: // Uncaught error event while(1); } uint32_t cmdStatus = ((volatile RF_Op*)&RF_cmdPropRx)->status; switch(cmdStatus) { case PROP_DONE_OK: // Packet received with CRC OK break; case PROP_DONE_RXERR: // Packet received with CRC error break; case PROP_DONE_RXTIMEOUT: // Observed end trigger while in sync search break; case PROP_DONE_BREAK: // Observed end trigger while receiving packet when the command is // configured with endType set to 1 break; case PROP_DONE_ENDED: // Received packet after having observed the end trigger; if the // command is configured with endType set to 0, the end trigger // will not terminate an ongoing reception break; case PROP_DONE_STOPPED: // received CMD_STOP after command started and, if sync found, // packet is received break; case PROP_DONE_ABORT: // Received CMD_ABORT after command started break; case PROP_ERROR_RXBUF: // No RX buffer large enough for the received data available at // the start of a packet break; case PROP_ERROR_RXFULL: // Out of RX buffer space during reception in a partial read break; case PROP_ERROR_PAR: // Observed illegal parameter break; case PROP_ERROR_NO_SETUP: // Command sent without setting up the radio in a supported // mode using CMD_PROP_RADIO_SETUP or CMD_RADIO_SETUP break; case PROP_ERROR_NO_FS: // Command sent without the synthesizer being programmed break; case PROP_ERROR_RXOVF: // RX overflow observed during operation break; default: // Uncaught error event - these could come from the // pool of states defined in rf_mailbox.h while(1); } 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 a pointer to the first IQ sample byte packetDataPointer = ¤tReadEntry->rxData; //--------------------------------------------------------------------------- // Implement code for handling the IQ data // . // . // . // . //--------------------------------------------------------------------------- currentReadEntry->status = DATA_ENTRY_PENDING; currentReadEntry = (rfc_dataEntryPartial_t*)currentReadEntry->pNextEntry; } }
//********************************************************************************* // Generated by SmartRF Studio version 2.13.1 (build #172) // Tested for SimpleLink SDK version: CC13x2 SDK 2.30.xx.xx // Device: CC1352P Rev. E (2.1) // //********************************************************************************* //********************************************************************************* // Parameter summary // Address: off // Address0: 0xAA // Address1: 0xBB // Frequency: 868.00000 MHz // Data Format: Serial mode disable // Deviation: 25.000 kHz // pktLen: 30 // 802.15.4g Mode: off // Select bit order to transmit PSDU octets:: 1 // Packet Length Config: Variable // Max Packet Length: 255 // Packet Length: 30 // Packet Data: 255 // RX Filter BW: 98.0 kHz // Symbol Rate: 50.00000 kBaud // Sync Word Length: 32 Bits // TX Power: 20 dBm (requires define CCFG_FORCE_VDDR_HH = 0 in ccfg.c, see CC13xx/CC26xx Technical Reference Manual) // Enable high output power PA: true // Whitening: No whitening #include <ti/devices/DeviceFamily.h> #include DeviceFamily_constructPath(driverlib/rf_mailbox.h) #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) #include <ti/drivers/rf/RF.h> //#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_prop.h) // TI-RTOS RF Mode Object #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_prop.h) #include DeviceFamily_constructPath(rf_patches/rf_patch_mce_iqdump.h) #include "smartrf_settings.h" // TI-RTOS RF Mode Object RF_Mode RF_prop = { .rfMode = RF_MODE_AUTO, .cpePatchFxn = &rf_patch_cpe_prop, .mcePatchFxn = &rf_patch_mce_iqdump, .rfePatchFxn = 0, }; // Overrides for CMD_PROP_RADIO_DIV_SETUP_PA uint32_t pOverrides[] = { // override_tc706.xml // Tx: Configure PA ramp time, PACTL2.RC=0x3 (in ADI0, set PACTL2[4:3]=0x3) // MCE_RFE_OVERRIDE(1,0,3,0,4,0), // CC13x2 ADI_2HALFREG_OVERRIDE(0,16,0x8,0x8,17,0x1,0x1), // Rx: Set AGC reference level to 0x1A (default: 0x2E) HW_REG_OVERRIDE(0x609C,0x001A), // Rx: Set RSSI offset to adjust reported RSSI by -1 dB (default: -2), trimmed for external bias and differential configuration (uint32_t)0x000188A3, // Rx: Set anti-aliasing filter bandwidth to 0xD (in ADI0, set IFAMPCTL3[7:4]=0xD) ADI_HALFREG_OVERRIDE(0,61,0xF,0xD), // override_prop_common.xml // DC/DC regulator: In Tx with 14 dBm PA setting, use DCDCCTL5[3:0]=0xF (DITHER_EN=1 and IPEAK=7). In Rx, use default settings. (uint32_t)0x00F788D3, #if (CCFG_FORCE_VDDR_HH) // TX power override // Tx: Set PA trim to max to maximize its output power (in ADI0, set PACTL0=0xF8) ADI_REG_OVERRIDE(0,12,0xF8), #endif (uint32_t)0xFFFFFFFF, (uint32_t)0x001082C3, //HW_REG_OVERRIDE(0x5328, 0x070D) // CC13x2 }; // Overrides for CMD_PROP_RADIO_DIV_SETUP_PA uint32_t pOverridesTxStd[] = { // The TX Power element should always be the first in the list TX_STD_POWER_OVERRIDE(0x013F), // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings (uint32_t)0x11310703, // override_phy_tx_pa_ramp_genfsk_std.xml // Tx: Configure PA ramping, set wait time before turning off (0x1A ticks of 16/24 us = 17.3 us). HW_REG_OVERRIDE(0x6028,0x001A), (uint32_t)0xFFFFFFFF, }; // Overrides for CMD_PROP_RADIO_DIV_SETUP_PA uint32_t pOverridesTx20[] = { // The TX Power element should always be the first in the list TX20_POWER_OVERRIDE(0x001B8ED2), // The ANADIV radio parameter based on the LO divider (0) and front-end (0) settings (uint32_t)0x11C10703, // override_phy_tx_pa_ramp_genfsk_hpa.xml // Tx: Configure PA ramping, set wait time before turning off (0x1F ticks of 16/24 us = 20.3 us). HW_REG_OVERRIDE(0x6028,0x001F), (uint32_t)0xFFFFFFFF, }; // CMD_PROP_RADIO_DIV_SETUP_PA // Proprietary Mode Radio Setup Command for All Frequency Bands rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t RF_cmdPropRadioDivSetup = { .commandNo = 0x3807, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = 0x0, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = 0x1, .condition.nSkip = 0x0, .modulation.modType = 0x1, .modulation.deviation = 0x19, .modulation.deviationStepSz = 0x0, .symbolRate.preScale = 0xF, .symbolRate.rateWord = 0x2000, .symbolRate.decimMode = 0x0, .rxBw = 0x4D, .preamConf.nPreamBytes = 0x4, .preamConf.preamMode = 0x0, .formatConf.nSwBits = 0x20, .formatConf.bBitReversal = 0x0, .formatConf.bMsbFirst = 0x0, .formatConf.fecMode = 0x0, .formatConf.whitenMode = 0x0, .config.frontEndMode = 0x0, .config.biasMode = 0x1, .config.analogCfgMode = 0x0, .config.bNoFsPowerUp = 0x0, .txPower = 0xFFFF, .pRegOverride = pOverrides, .centerFreq = 0x0364, .intFreq = 0x8000, .loDivider = 0x05, .pRegOverrideTxStd = pOverridesTxStd, .pRegOverrideTx20 = pOverridesTx20, }; // CMD_FS // Frequency Synthesizer Programming Command rfc_CMD_FS_t RF_cmdFs = { .commandNo = 0x0803, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = 0x0, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = 0x1, .condition.nSkip = 0x0, .frequency = 0x0364, .fractFreq = 0x0000, .synthConf.bTxMode = 0x0, .synthConf.refFreq = 0x0, .__dummy0 = 0x00, .__dummy1 = 0x00, .__dummy2 = 0x00, .__dummy3 = 0x0000, }; // CMD_PROP_TX // Proprietary Mode Transmit Command rfc_CMD_PROP_TX_t RF_cmdPropTx = { .commandNo = 0x3801, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = 0x0, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = 0x1, .condition.nSkip = 0x0, .pktConf.bFsOff = 0x0, .pktConf.bUseCrc = 0x1, .pktConf.bVarLen = 0x1, .pktLen = 0x1E, // SET APPLICATION PAYLOAD LENGTH .syncWord = 0x930B51DE, .pPkt = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx }; // CMD_PROP_RX // Proprietary Mode Receive Command rfc_CMD_PROP_RX_t RF_cmdPropRx = { .commandNo = 0x3802, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = 0x0, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = 0x1, .condition.nSkip = 0x0, .pktConf.bFsOff = 0x0, .pktConf.bRepeatOk = 0x0, .pktConf.bRepeatNok = 0x0, .pktConf.bUseCrc = 0x1, .pktConf.bVarLen = 0x1, .pktConf.bChkAddress = 0x0, .pktConf.endType = 0x0, .pktConf.filterOp = 0x0, .rxConf.bAutoFlushIgnored = 0x0, .rxConf.bAutoFlushCrcErr = 0x0, .rxConf.bIncludeHdr = 0x1, .rxConf.bIncludeCrc = 0x0, .rxConf.bAppendRssi = 0x0, .rxConf.bAppendTimestamp = 0x0, .rxConf.bAppendStatus = 0x1, .syncWord = 0x930B51DE, .maxPktLen = 0x0, // MAKE SURE DATA ENTRY IS LARGE ENOUGH .address0 = 0xAA, .address1 = 0xBB, .endTrigger.triggerType = 0x1, .endTrigger.bEnaCmd = 0x0, .endTrigger.triggerNo = 0x0, .endTrigger.pastTrig = 0x0, .endTime = 0x00000000, .pQueue = 0, // INSERT APPLICABLE POINTER: (dataQueue_t*)&xxx .pOutput = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx }; // CMD_TX_TEST rfc_CMD_TX_TEST_t RF_cmdTxTest = { .commandNo = 0x0808, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = 0x0, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = 0x1, .condition.nSkip = 0x0, .config.bUseCw = 0x0, .config.bFsOff = 0x1, .config.whitenMode = 0x2, .__dummy0 = 0x00, .txWord = 0xAAAA, .__dummy1 = 0x00, .endTrigger.triggerType = 0x1, .endTrigger.bEnaCmd = 0x0, .endTrigger.triggerNo = 0x0, .endTrigger.pastTrig = 0x0, .syncWord = 0x930B51DE, .endTime = 0x00000000, };
Thank you very much!