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.
Tool/software:
Dear TI Support Team,
I am writing to seek assistance regarding an issue I encountered while working with the CC2340R2 chip. I followed the guidelines to modify the flash macro definitions, switched the chip model in SysConfig, cleared previous build information, and reprogrammed the device. The code that was functioning perfectly on the CC2340R5, continuously transmitting Bluetooth iBeacon data, fails to transmit any data on the CC2340R2.
For the hardware modifications, we replaced the chip on the LP-EM-CC2340R5 demo board with the CC2340R2. I conducted tests using SmartRF Studio 8, and the results showed successful data transmission on channels 37, 38, and 39, confirming that the hardware setup is operational.
Could you provide any solutions or guidance on configuring the project to address this issue on the software side? Your assistance would be greatly appreciated.
Thank you for your support.
Best regards
I have reselected the chip and resolved the issue of no data being sent. However, a new problem has emerged: the delay added in the while loop can only go up to around 190ms, and increasing it further doesn’t work. Even multiple calls to the delay function are ineffective. This code works perfectly on the CC2340r5, so the issue likely occurred during the SDK migration process. Could you provide an effective solution for this?
Hi,
I have assigned an expert to support.
Please provide a code snippet showing the way you are using the device.
Also, it looks like you are trying to mimic Bluetooth advertising, but at the same time it seems you are not using the Bluetooth stack. Could you please explain why you have selected this approach?
Best regards,
这是 rfPacketTx.c
/* * Copyright (c) 2013-2022, 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> #include <stdio.h> #include <unistd.h> #include <limits.h> /* TI Drivers */ #include <ti/drivers/GPIO.h> #include <ti/drivers/rcl/RCL.h> #include <ti/drivers/rcl/RCL_Scheduler.h> #include <ti/drivers/rcl/commands/generic.h> /* SysConfig Generated */ #include "ti_drivers_config.h" //#include "ti_radio_config.h" #include "rcl_settings_generic.h" #include "ble_adv.h" #include <time.h> //#include <hci_tl.h> /***** Defines *****/ /* Packet TX Configuration */ #define MAX_LENGTH (30U) // Max packet length #define NUM_DATA_ENTRIES (2U) // Number of data entries #define NUM_PAD_BYTES (3U) // Number of pad bytes #define PACKET_INTERVAL 50000//500000 // Set packet interval to 500000us or 500ms /* The index of the length in the TX packet and the length of the header */ #define LEN_INDEX (RCL_REGISTER_FIELD_PBE_GENERIC_RAM_LENCFG_LENPOS/CHAR_BIT) #define HDR_LEN (LEN_INDEX + (RCL_REGISTER_FIELD_PBE_GENERIC_RAM_LENCFG_NUMLENBITS/CHAR_BIT)) /* Indicates if FS is off */ #define FS_OFF (1U) // 0: On, 1: Off #define FREQUENCY (2426000000U) #define CHANNEL37 (2402000000U) #define CHANNEL38 (2426000000U) #define CHANNEL39 (2480000000U) /***** Variable declarations *****/ /* RCL Commands */ extern RCL_CmdGenericTx rclPacketTxCmdGenericTx_test; /* RCL Client used to open RCL */ static RCL_Client rclClient; static RCL_Client rclClient38; static RCL_Client rclClient39; /* TX packet buffer */ uint32_t packet[NUM_DATA_ENTRIES][3 + ((MAX_LENGTH + 10)/ 4)]; /* Counters for RCL event callback */ volatile uint32_t gCmdDone = 0; // Command done /***** Callback Functions *****/ void defaultCallback(RCL_Command *cmd, LRF_Events lrfEvents, RCL_Events rclEvents) { // if (rclEvents.lastCmdDone) // { // gCmdDone += 1; // // GPIO_toggle(CONFIG_GPIO_GLED); // } } RCL_Handle rclHandle ; RCL_Handle rclHandle38 ; RCL_Handle rclHandle39 ; RCL_Buffer_TxBuffer *txPacket; static ibeacon_t ibeacon_data; uint8_t *txData; //void txbuffer_init() //{ // RCL_Buffer_TxBuffer *txPacket = (RCL_Buffer_TxBuffer *)&packet; //} /***** Function definitions *****/ void *mainThread(void *arg0) { /* Initialize and open RCL */ RCL_init(); rclHandle = RCL_open(&rclClient, &LRF_config_test); rclHandle38 = RCL_open(&rclClient38, &LRF_config_test38); rclHandle39 = RCL_open(&rclClient39, &LRF_config_test39); /* Set RF frequency */ rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL37; /* Start command as soon as possible */ rclPacketTxCmdGenericTx_test.common.scheduling = RCL_Schedule_Now; rclPacketTxCmdGenericTx_test.common.status = RCL_CommandStatus_Idle; rclPacketTxCmdGenericTx_test.config.fsOff = FS_OFF; // Turn off FS /* Callback triggers on last command done */ rclPacketTxCmdGenericTx_test.common.runtime.callback = defaultCallback; rclPacketTxCmdGenericTx_test.common.runtime.rclCallbackMask.value = RCL_EventLastCmdDone.value; /* Set RCL TX buffer packet to be packet buffer */ txPacket = (RCL_Buffer_TxBuffer *)&packet; // GPIO_setConfig(CONFIG_GPIO_GLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); // GPIO_write(CONFIG_GPIO_GLED, CONFIG_GPIO_LED_OFF); /* Create packet with random payload */ txData = RCL_TxBuffer_init(txPacket, NUM_PAD_BYTES, HDR_LEN, MAX_LENGTH); /* Zero out data in header before the length field */ for (int s = 0; s < LEN_INDEX; s++) { txData[s] = 0U; } /* Set the packet length */ txData[LEN_INDEX] = MAX_LENGTH; launch_time_init(); tx_buffer_init(&ibeacon_data); memcpy(&txData[HDR_LEN],&ibeacon_data,sizeof(ibeacon_data)); // /* Create packet with random payload */ // uint8_t *txData; // txData = RCL_TxBuffer_init(txPacket, NUM_PAD_BYTES, HDR_LEN, MAX_LENGTH); // // /* Zero out data in header before the length field */ // for (int s = 0; s < LEN_INDEX; s++) // { // txData[s] = 0U; // } // // /* Set the packet length */ // txData[LEN_INDEX] = MAX_LENGTH; // // /* Generate a random payload */ // for (int i = HDR_LEN; i < MAX_LENGTH; i++) // { // txData[i] = rand(); // } /* Set packet to transmit */ // RCL_TxBuffer_put(&rclPacketTxCmdGenericTx_test.txBuffers, txPacket); // rclPacketTxCmdGenericTx_test.common.status = RCL_CommandStatus_Idle; // // /* Submit command */ // RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx_test); while(1) { switch_channel(37); switch_channel(38); switch_channel(39); // usleep((325+get_next_launch_time())*1000); // usleep((100)*1000); // usleep((100)*1000); // usleep((100)*1000); vTaskDelay(330); } } void switch_channel(uint8_t channel) { // { // switch(channel) // { // case 37: // rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL37; // break; // case 38: // rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL38; // break; // case 39: // rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL39; // break; // // default: // break; // } //// switch_white(channel); //// rclHandle = RCL_open(&rclClient, &LRF_config_test); // } { // tx_buffer_update(channel,(ibeacon_t *)&txData[HDR_LEN]); RCL_TxBuffer_put(&rclPacketTxCmdGenericTx_test.txBuffers, txPacket); rclPacketTxCmdGenericTx_test.common.status = RCL_CommandStatus_Idle; { switch(channel) { case 37: // RCL_TxBuffer_put(&rclPacketTxCmdGenericTx_test.txBuffers, txPacket); rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL37; RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx_test); break; case 38: rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL38; RCL_Command_submit(rclHandle38, &rclPacketTxCmdGenericTx_test); break; case 39: rclPacketTxCmdGenericTx_test.rfFrequency = CHANNEL39; RCL_Command_submit(rclHandle39, &rclPacketTxCmdGenericTx_test); break; default: break; } } // RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx_test); RCL_Command_pend(&rclPacketTxCmdGenericTx_test); // uint32_t flag = 0; // while((flag++)<40000); // RCL_close(rclHandle); } }
这是 main_freertos.c
/* * Copyright (c) 2013-2022, 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. */ /* * ======== main_freertos.c ======== */ #include <stdint.h> #ifdef __ICCARM__ #include <DLib_Threads.h> #endif /* POSIX Header files */ #include <pthread.h> /* RTOS header files */ #include <FreeRTOS.h> #include <task.h> #include <ti/drivers/Board.h> extern void *mainThread(void *arg0); /* Stack size in bytes */ #define THREADSTACKSIZE 2048 /* * ======== main ======== */ int main(void) { pthread_t thread; pthread_attr_t attrs; struct sched_param priParam; int retc; /* initialize the system locks */ #ifdef __ICCARM__ __iar_Initlocks(); #endif Board_init(); /* Initialize the attributes structure with default values */ pthread_attr_init(&attrs); /* Set priority, detach state, and stack size attributes */ priParam.sched_priority = 1; retc = pthread_attr_setschedparam(&attrs, &priParam); retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED); retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE); if (retc != 0) { /* failed to set attributes */ while (1) {} } retc = pthread_create(&thread, &attrs, mainThread, NULL); if (retc != 0) { /* pthread_create() failed */ while (1) {} } /* Start the FreeRTOS scheduler */ vTaskStartScheduler(); return (0); }
This is a part of the code snippet and configuration information. Regarding the above issue, we hope to find a solution. We didn’t use the Bluetooth stack because we have higher requirements for its power consumption. We hope to achieve our functionality with lower power consumption.
Additionally, during testing, I discovered a peculiar issue. As mentioned earlier, we are using the LP-EM-CC2340R5 demo board. Following the adaptation guide, I set the board to CC2340R22 on LP_EM_CC2340R5. Even after changing the flash size, no functionality seemed to work. When I selected the board as CC2340R2 Development Platform and adjusted the flash size, Bluetooth data could be sent normally, but the above issue occurred. I tried to troubleshoot whether the radio transmission was affecting the delay by commenting out the send interface and replacing it with an LED, but it seems that the pins in syscfg do not correspond to the actual pins. I hope you can provide support to help us resolve these issues. Thank you!
Hello Wenbo Hu,
I hope you are doing well.
but it seems that the pins in syscfg do not correspond to the actual pins
-we can try to see if there is a difference by comparing what Syscfg thinks the pins are, vs what pin setup we are trying to use, reference the custom HW in the SDK documentation BLE5-Stack Quick Start Guide (ti.com)
We didn’t use the Bluetooth stack because we have higher requirements for its power consumption.
-We do provide a proprf PHY that can replicate BLE like packets, but without the BLE stack, and this is what you are currently using, the issue here is that your application code (delay) is not working, if you place a breakpoint at the delay what happens?
Thanks,
Alex F
Hello Alex Fager,
I hope you are doing well.
I’m sorry, this issue has not been resolved, but I accidentally clicked this button with my mouse.
I set a breakpoint at the delay function for debugging and found that the delay function entered normally while also performing thread scheduling operations. Then I replaced the delay function with vTaskDelayUntil(), and found that the same issue occurred—the maximum delay could only be 200ms. Can you provide a solution or relevant examples that work correctly?
Alternatively, to simplify the problem, we are using the CC2340R2 chip on the LP-EM-CC2340R5 demo board. We followed the migration guide to transfer the “ti\simplelink_lowpower_f3_sdk_8_10_01_02\examples\rtos\LP_EM_CC2340R5\drivers\buttonled\freertos\ticlang” example to CC2340R2, but found it didn’t work. Can you provide operational guidance or examples related to CC2340R2?
Thanks,
Wenbo Hu
Hello Wenbo Hu,
Here is a quick code snippet from rfpacketTx I modified with vTaskDelay();
I also added in syscfg the LNA pins (under RCL).
This helps me check the timing with a logic analyzer of ~1.3 s delay (800 ms from vTaskDelay and 500 ms from usleep)
Can you see what the LNA pins tell you?
Thanks,
Alex F
Alex Fager, I’m glad to receive your response and appreciate the validation results you’ve provided. However, the issue I’m facing is not yet resolved. I’ll now walk you through my steps so that you can help identify the problem.
First, I imported a CC2340R5 chip that was modified and verified based on “rfPacketTx.” Then, I clicked on syscfg, selected SWITCH, and chose “CC2340R2 Development Platform” in the board options. I also tried selecting “CC2340R22 on LP_EM_CC2340R5,” but when I chose this option, I couldn’t capture any BLE data, and importing other examples with this option didn’t work properly either.
Next, I opened the file “lpf3_freertos.cmd” and modified the macro definition “#define FLASH_SIZE 0X40000”. Finally, I compiled the project and flashed it onto the demo board. The issue was reproduced with these steps.
Do you see any potential oversights in my operations that might be causing the problem?
I have attached my operation steps screenshots and the project generated according to the above steps.
Hello,
I will take a look at your described steps above! and also consult one of my team members.
Thanks,
Alex F
Hello Wenbo Hu,
I apologize for the delay here, I should be able to give you a response sometime today.
Thank you,
Alex F
Hello Wenbo Hu,
I got a R2 board and I am migrating the project, currently dealing with an issue where the RCL LNA pins do not seem to be working (or that the radio is not active).
Thanks,
Alex F
Hello Wenbo Hu,
I got the rfPacketTX project working and have modified the "delay" reference code snippet below:
In this case I followed the migration steps from BLE5-Stack Migration Guide, but did not modify the lpf3_freertos.cmd file for reference.
void *mainThread(void *arg0) { /* Initialize and open RCL */ RCL_init(); RCL_Handle rclHandle = RCL_open(&rclClient, &LRF_config); /* Set RF frequency */ rclPacketTxCmdGenericTx.rfFrequency = FREQUENCY; /* Start command as soon as possible */ rclPacketTxCmdGenericTx.common.scheduling = RCL_Schedule_Now; rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle; rclPacketTxCmdGenericTx.config.fsOff = FS_OFF; // Turn off FS /* Callback triggers on last command done */ rclPacketTxCmdGenericTx.common.runtime.callback = defaultCallback; rclPacketTxCmdGenericTx.common.runtime.rclCallbackMask.value = RCL_EventLastCmdDone.value; /* Set RCL TX buffer packet to be packet buffer */ RCL_Buffer_TxBuffer *txPacket = (RCL_Buffer_TxBuffer *)&packet; GPIO_setConfig(CONFIG_GPIO_GLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_write(CONFIG_GPIO_GLED, CONFIG_GPIO_LED_OFF); while(1) { /* Create packet with random payload */ uint8_t *txData; txData = RCL_TxBuffer_init(txPacket, NUM_PAD_BYTES, HDR_LEN, MAX_LENGTH); /* Zero out data in header before the length field */ for (int s = 0; s < LEN_INDEX; s++) { txData[s] = 0U; } /* Set the packet length */ txData[LEN_INDEX] = MAX_LENGTH; /* Generate a random payload */ for (int i = HDR_LEN; i < MAX_LENGTH; i++) { txData[i] = rand(); } /* Set packet to transmit */ RCL_TxBuffer_put(&rclPacketTxCmdGenericTx.txBuffers, txPacket); rclPacketTxCmdGenericTx.common.status = RCL_CommandStatus_Idle; /* Submit command */ RCL_Command_submit(rclHandle, &rclPacketTxCmdGenericTx); /* Pend on command completion */ RCL_Command_pend(&rclPacketTxCmdGenericTx); //usleep(PACKET_INTERVAL); sleep(1); } }
rfPacketTx_LP_EM_CC2340R5_freertos_ticlang.zip
Thanks,
Alex F
Alex_Fager
Thank you for your help. My colleagues and I will verify the engineering you provided and feedback the results to you. Thank you!
Thanks,