Part Number:CC2650EM-7ID-RD
Hello, I'm User who using SimpleLink CC2650 Development Kit.
i'm trying to communicate between two board with Bluetooth. i have set up 2 board(one is Tx mode, another is Rx mode).
and in Rx side, i'm trying to check the packet value via workspace console window.
but when i'm check the value, the values is always like below.
[Cortex_M3_0] 0->30
1->0
2->16
3->0
4->0
5->0
6->0
7->0
8->0
9->0
10->0
11->0
12->0
13->0
14->0
15->0
16->0
17->0
18->0
19->0
20->0
21->0
22->0
23->0
24->0
25->0
26->0
27->0
28->0
29->0
30->0
31->0
32->0
33->0
34->0
35->0
36->0
37->0
38->0
39->0
40->0
41->0
42->0
43->0
44->0
45->0
46->0
47->0
48->0
49->0
50->0
51->0
52->0
53->0
54->0
55->0
56->0
57->0
58->0
59->0
60->0
61->0
62->0
63->0
64->0
65->0
66->0
67->0
68->0
69->0
70->0
71->0
72->0
73->0
74->0
75->0
76->0
77->0
78->0
79->0
80->0
81->0
82->0
83->0
84->0
85->0
86->0
87->0
88->0
89->0
90->0
91->0
92->0
93->0
94->0
95->0
96->0
97->0
98->0
99->0
100->0
101->0
102->0
103->0
104->0
105->0
106->0
107->0
108->0
109->0
110->0
111->0
112->0
113->0
114->0
115->0
116->0
117->0
118->0
119->0
120->0
121->0
122->0
123->0
124->0
125->0
126->0
0->30
1->0
2->16
3->0
4->0
5->0
6->0
7->0
8->0
9->0
10->0
11->0
12->0
13->0
14->0
15->0
16->0
17->0
18->0
19->0
20->0
21->0
22->0
23->0
24->0
25->0
26->0
27->0
28->0
29->0
30->0
31->0
32->0
33->0
34->0
35->0
36->0
37->0
38->0
39->0
40->0
41->0
42->0
43->0
44->0
45->0
46->0
47->0
48->0
49->0
50->0
51->0
52->0
53->0
54->0
55->0
56->0
57->0
58->0
59->0
60->0
61->0
62->0
63->0
64->0
65->0
66->0
67->0
68->0
69->0
70->0
71->0
72->0
73->0
74->0
75->0
76->0
77->0
78->0
79->0
80->0
81->0
82->0
83->0
84->0
85->0
86->0
87->0
88->0
89->0
90->0
91->0
92->0
93->0
94->0
95->0
96->0
97->0
98->0
99->0
100->0
101->0
102->0
103->0
104->0
105->0
106->0
107->0
108->0
109->0
110->0
111->0
112->0
113->0
114->0
115->0
116->0
117->0
118->0
119->0
120->0
121->0
122->0
123->0
124->0
125->0
126->0
From the Tx side code, 0-1 index will be contain Sequence number and then other parts must contain random values. but it isn't.
what am i missing?
---------------------------------------------------------------------------------------------RX side Code------------------------------------------------------------------------
/***** Includes *****/ /* XDCtools Header files */ #include <xdc/runtime/Assert.h> #include <xdc/runtime/System.h> #include <xdc/std.h> /* TI-RTOS Header files */ #include <ti/drivers/rf/RF.h> #include <ti/drivers/PIN.h> /* Board Header files */ #include "Board.h" /* Application specific Header files */ #include "menu.h" #include "RFQueue.h" #include "smartrf_settings/smartrf_settings.h" #include "smartrf_settings/smartrf_settings_predefined.h" #if (defined __CC2650EM_7ID_H__) || (defined __CC2650_LAUNCHXL_BOARD_H__) || (defined __CC1350_LAUNCHXL_BOARD_H__) || (defined __CC1350STK_SENSORTAG_BOARD_H__) #include "smartrf_settings/smartrf_settings_ble.h" #endif /***** Defines *****/ #define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */ #define MAX_LENGTH 10 /* 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 /* RF_cmdRxHS.rxConf.bIncludeLen = 1: Include the received length * field (2 bytes) in the stored packet */ static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */ int i=0; /***** Prototypes *****/ static void rx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e); /***** Variable declarations *****/ static uint8_t packetReceived = false; static uint16_t* crcOk; static int8_t* rssi; static RF_Object rfObject; static RF_Handle rfHandle; static RF_CmdHandle rxCmdHndl = NULL; /* Handle needed to abot the RX command */ /* 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)]; #endif static dataQueue_t dataQueue; /* Receive queue for the RF Code to fill in data */ rfc_dataEntryGeneral_t* currentDataEntry; /* General data entry structure (type = 0) */ #if (defined __CC2650EM_7ID_H__) || (defined __CC2650_LAUNCHXL_BOARD_H__) || (defined __CC1350_LAUNCHXL_BOARD_H__) || (defined __CC1350STK_SENSORTAG_BOARD_H__) rfc_bleGenericRxOutput_t rxStatistics_ble; /* Output structure for RF_ble_cmdBleGenericRx */ #endif rfc_propRxOutput_t rxStatistics_prop; /* Output structure for CMD_PROP_RX */ /* Runs the receiving part of the test application and returns a result. */ TestResult rx_runRxTest(const ApplicationConfig* config) { Assert_isTrue(config != NULL, NULL); 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(true); } RF_cmdPropRx.pQueue = &dataQueue; RF_cmdPropRx.pOutput = (uint8_t*)&rxStatistics_prop; RF_cmdPropRx.maxPktLen = MAX_LENGTH; RF_cmdPropRx.pktConf.bRepeatOk = 1; RF_cmdPropRx.pktConf.bRepeatNok = 1; RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; RF_ble_pCmdBleGenericRx->pOutput = &rxStatistics_ble; RF_ble_pCmdBleGenericRx->pParams->pRxQ = &dataQueue; RF_ble_pCmdBleGenericRx->pParams->bRepeat = 1; RF_ble_pCmdBleGenericRx->pParams->rxConfig.bAutoFlushCrcErr = 1; RF_ble_pCmdBleGenericRx->channel = 0xFF; RF_ble_pCmdBleGenericRx->whitening.bOverride = 1; RF_ble_pCmdBleGenericRx->whitening.init = config->frequencyTable[config->frequency].whitening; /* Request access to the radio based on test case */ switch (config->rfSetup) { case RfSetup_Custom: rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); break; case RfSetup_Fsk: rfHandle = RF_open(&rfObject, RF_pProp_2_4G_fsk, (RF_RadioSetup*)RF_pCmdPropRadioSetup_2_4G_fsk, &rfParams); break; case RfSetup_Ble: rfHandle = RF_open(&rfObject, RF_pModeBle, (RF_RadioSetup*)RF_ble_pCmdRadioSetup, &rfParams); break; default: break; } /* Set the frequency */ if(config->rfSetup == RfSetup_Custom) { //Custom settings exported from SmartRf studio shall use the exported frequency RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); } else if(config->rfSetup == RfSetup_Ble) { RF_ble_pCmdFs->frequency = config->frequencyTable[config->frequency].frequency; RF_ble_pCmdFs->fractFreq = config->frequencyTable[config->frequency].fractFreq; RF_runCmd(rfHandle, (RF_Op*)RF_ble_pCmdFs, RF_PriorityNormal, NULL, 0); } else { RF_pCmdFs_preDef->frequency = config->frequencyTable[config->frequency].frequency; RF_pCmdFs_preDef->fractFreq = config->frequencyTable[config->frequency].fractFreq; RF_runCmd(rfHandle, (RF_Op*)RF_pCmdFs_preDef, RF_PriorityNormal, NULL, 0); } /* Enter RX mode and stay forever in RX */ switch (config->rfSetup) { case RfSetup_Ble: rxCmdHndl = RF_postCmd(rfHandle, (RF_Op*)RF_ble_pCmdBleGenericRx, RF_PriorityNormal, &rx_callback, RF_EventRxEntryDone); crcOk = &rxStatistics_ble.nRxOk; rssi = &rxStatistics_ble.lastRssi; break; default: rxCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rx_callback, RF_EventRxEntryDone); crcOk = &rxStatistics_prop.nRxOk; rssi = &rxStatistics_prop.lastRssi; break; } *crcOk = 0; *rssi = 0; while(true) { if(packetReceived) { packetReceived = false; menu_updateRxScreen(*crcOk, *rssi); } if (menu_isButtonPressed()) { /* force abort gracefully */ RF_cancelCmd(rfHandle, rxCmdHndl, 0); RF_pendCmd(rfHandle, rxCmdHndl, RF_EventRxEntryDone); RF_close(rfHandle); return TestResult_Aborted; } } } void rx_callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e) { if (e & RF_EventRxEntryDone) { /* Get current unhandled data entry */ currentDataEntry = RFQueue_getDataEntry(); /* For TC_HSM, the packet length and a pointer to the first byte in the payload can be found as follows: */ // uint8_t packetLength = ((*(uint8_t*)(¤tDataEntry->data + 1)) << 8) | (*(uint8_t*)(¤tDataEntry->data)); // uint8_t* packetDataPointer = (uint8_t*)(¤tDataEntry->data + 2); /// For the other test cases (TC_LRM, TC_OOK and TC_FSK), the packet length and first payload byte is found here: uint8_t packetLength = *(uint8_t*)(¤tDataEntry->data); uint8_t* packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1); //packetLength = *(uint8_t*)(¤tDataEntry->data); //packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1); memcpy(packet, packetDataPointer, (packetLength + 1)); for(i=0; i<= (MAX_LENGTH + NUM_APPENDED_BYTES - 1); i++){ System_printf("%d->%d\n", i, packet[i]); } packetReceived = true; RFQueue_nextEntry(); } }
-------------------------------------------------------------------------------------------------TX side Code-------------------------------------------------------------------------------------
/***** Includes *****/ /* XDCtools Header files */ #include <xdc/runtime/Assert.h> #include <xdc/runtime/System.h> #include <xdc/std.h> /* TI-RTOS Header files */ #include <ti/drivers/rf/RF.h> #include <ti/drivers/PIN.h> /* Board Header files */ #include "Board.h" /* Application specific Header files */ #include <stdlib.h> #include "menu.h" #include "RFQueue.h" #include "smartrf_settings/smartrf_settings.h" #include "smartrf_settings/smartrf_settings_predefined.h" #if (defined __CC2650EM_7ID_H__) || (defined __CC2650_LAUNCHXL_BOARD_H__) || (defined __CC1350_LAUNCHXL_BOARD_H__) || (defined __CC1350STK_SENSORTAG_BOARD_H__) #include "smartrf_settings/smartrf_settings_ble.h" #endif /***** Defines *****/ #define PAYLOAD_LENGTH 4 /* Length of the packet to send */ #define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */ #define MAX_LENGTH 4 /* Set the length of the data entry */ #define NUM_DATA_ENTRIES 1 #define NUM_APPENDED_BYTES 0 /***** Variable declarations *****/ static RF_Object rfObject; static RF_Handle rfHandle; static uint8_t packet[PAYLOAD_LENGTH]; static uint16_t seqNumber; uint32_t packetCounter = 0; uint32_t packetInterval; #if defined(__TI_COMPILER_VERSION__) #pragma DATA_ALIGN (txDataEntryBuffer, 4); static uint8_t txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)]; #endif /* Tx queue or RF Core to read data from */ static dataQueue_t dataQueue; static rfc_dataEntryGeneral_t* currentDataEntry; static uint8_t *pPacket; /* Runs the receiving part of the test application and returns a result. */ TestResult tx_runTxTest(const ApplicationConfig* config) { Assert_isTrue(config != NULL, NULL); uint32_t time; RF_Params rfParams; RF_Params_init(&rfParams); RF_cmdPropTx.pktLen = PAYLOAD_LENGTH; RF_cmdPropTx.pPkt = packet; RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME; RF_cmdPropTx.startTrigger.pastTrig = 1; RF_cmdPropTx.startTime = 0; if( RFQueue_defineQueue(&dataQueue, txDataEntryBuffer, sizeof(txDataEntryBuffer), NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES)) { /* Failed to allocate space for all data entries */ while(true); } #if (defined __CC2650EM_7ID_H__) || (defined __CC2650_LAUNCHXL_BOARD_H__) || (defined __CC1350_LAUNCHXL_BOARD_H__) || (defined __CC1350STK_SENSORTAG_BOARD_H__) RF_ble_pCmdBleAdvNc->pParams->pAdvData = packet; RF_ble_pCmdBleAdvNc->startTrigger.triggerType = TRIG_ABSTIME; RF_ble_pCmdBleAdvNc->startTrigger.pastTrig = 1; RF_ble_pCmdBleAdvNc->channel = 0xFF; RF_ble_pCmdBleAdvNc->whitening.bOverride = 1; RF_ble_pCmdBleAdvNc->whitening.init = config->frequencyTable[config->frequency].whitening; RF_ble_pCmdBleAdvNc->startTime = 0; #endif currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer; currentDataEntry->length = PAYLOAD_LENGTH; pPacket = ¤tDataEntry->data; /* Request access to the radio based on test case*/ switch (config->rfSetup) { case RfSetup_Custom: rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); break; case RfSetup_Fsk: rfHandle = RF_open(&rfObject, RF_pProp_2_4G_fsk, (RF_RadioSetup*)RF_pCmdPropRadioSetup_2_4G_fsk, &rfParams); packetInterval = (uint32_t)(4000000*0.05f); /* Set packet interval to 50 ms */ break; #if (defined __CC2650EM_7ID_H__) || (defined __CC2650_LAUNCHXL_BOARD_H__) || (defined __CC1350_LAUNCHXL_BOARD_H__) || (defined __CC1350STK_SENSORTAG_BOARD_H__) case RfSetup_Ble: rfHandle = RF_open(&rfObject, RF_pModeBle, (RF_RadioSetup*)RF_ble_pCmdRadioSetup, &rfParams); packetInterval = (uint32_t)(4000000*0.1f); /* Set packet interval to 100 ms */ break; #endif default: break; } /* Set the frequency */ if(config->rfSetup == RfSetup_Custom) { //Custom settings exported from SmartRf studio shall use the exported frequency RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); } else if(config->rfSetup == RfSetup_Ble) { RF_ble_pCmdFs->frequency = config->frequencyTable[config->frequency].frequency; RF_ble_pCmdFs->fractFreq = config->frequencyTable[config->frequency].fractFreq; RF_runCmd(rfHandle, (RF_Op*)RF_ble_pCmdFs, RF_PriorityNormal, NULL, 0); } else { RF_pCmdFs_preDef->frequency = config->frequencyTable[config->frequency].frequency; RF_pCmdFs_preDef->fractFreq = config->frequencyTable[config->frequency].fractFreq; RF_runCmd(rfHandle, (RF_Op*)RF_pCmdFs_preDef, RF_PriorityNormal, NULL, 0); } /* Get current time */ time = RF_getCurrentTime(); while (++packetCounter <= config->packetCount) { /* Create packet with incrementing sequence number and random payload */ pPacket[0] = packet[0] = (uint8_t)(seqNumber >> 8); pPacket[1] = packet[1] = (uint8_t)(seqNumber++); uint8_t i; for (i = 2; i < PAYLOAD_LENGTH; i++) { pPacket[i] = packet[i] = rand(); } /* Set absolute TX time to utilize automatic power management */ time += packetInterval; RF_cmdPropTx.startTime = time; /* Send packet */ switch (config->rfSetup) { case RfSetup_Ble: { RF_ble_pCmdBleAdvNc->startTime = time; RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)RF_ble_pCmdBleAdvNc, RF_PriorityNormal, NULL, 0); if (!(result & RF_EventLastCmdDone)) { /* Error */ while(true); } break; } default: { RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0); if (!(result & RF_EventLastCmdDone)) { /* Error */ while(true); } break; } } /* Update the display */ menu_updateTxScreen(packetCounter); /* Check, whether a button has been pressed */ if (menu_isButtonPressed()) { packetCounter = 0; seqNumber = 0; RF_close(rfHandle); return TestResult_Aborted; } } packetCounter = 0; seqNumber = 0; RF_close(rfHandle); return TestResult_Finished; }