Hello, everyone!
I want to dynamically change tx power of CC1310 from 10dBm to 14dBm when running application. How should I do?
Best Regards,
Gilbert
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.
Hello, everyone!
I want to dynamically change tx power of CC1310 from 10dBm to 14dBm when running application. How should I do?
Best Regards,
Gilbert
Hello Gilbert,
When you say dynamically change txPower, I am assuming that the power switch is not with in a packet but from one packet to the next. To achieve this you can run RF_yield(rfHandle), and then set the txPower to the desired value as shown below.
/* Set power to 10dBm */
RF_cmdPropRadioDivSetup.txPower = 0x38D3;
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
/* Change power to 14dBm */
RF_yield(rfHandle);
RF_cmdPropRadioDivSetup.txPower = 0xA73F;
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
Gilbert,
There are a couple ways to do this, but the simplest would be to use RF_runImmediateCmd ( RF_Handle h, uint32_t * pCmdStruct ), and pass in the CMD_SET_TX_POWER command struct (described in detail in the reference manual). The .txpower values should be taken from SmartRF Studio. Keep in mind that you will need to define CCFG_FORCE_VDDR_HH = 1 in ccfg.c in order to set TX power to 14dBm.
Here is an example of how you can set this up:
// in smartrf_settings.c and .h files #define TX_POWER_14 = 0xa73f; // define CCFG_FORCE_VDDR_HH = 1 in ccfg.c #define TX_POWER_10 = 0x38d3; rfc_CMD_SET_TX_POWER_t RF_cmdSetTxPower = { .commandNo = 0x0010, .txpower = TX_POWER_14, };
// in application code RF_Handle rfHandle; RF_Stat rfStat; /* open radio with the setup command */ // set TX power RF_cmdSetTxPower.txpower = TX_POWER_10; rfStat = RF_runImmediateCmd(rfHandle,(uint32_t*) RF_cmdSetTxPower); /* check rfStat for command status */ /* perform radio functions */
Skyler
Hello.
I would also like to dynamically increase the TX power after a set of packages (20 or so) in 2dBm steps from 0 (0x0041) to 12 (0xB818).
I tried to make a code by using the examples from this forum entry, but I am getting stuck. At the moment I can send 19 packets, and then the transmission stops.
Would you be able to help me please?
This is part of the code:
static void txTaskFunction(UArg arg0, UArg arg1)
{
uint32_t time;
RF_Params rfParams;
RF_Params_init(&rfParams);
// Power changes
uint8_t txpowerlevelmode;
const uint16_t txpowerlevel[] = {0x0041,0x1042,0x18c5,0x1cc7,0x24cb,0x38d3,0xb818};
txpowerlevelmode = 0;
RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
RF_cmdPropTx.pPkt = packet;
RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
RF_cmdPropTx.startTrigger.pastTrig = 1;
RF_cmdPropTx.startTime = 0;
/* Request access to the radio */
//RF_cmdPropRadioDivSetup.txPower = txpowerlevel[txpowerlevelmode];
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);
/* Get current time */
time = RF_getCurrentTime();
while(1)
{
/* Create packet with incrementing sequence number and random payload */
packet[0] = (uint8_t)(seqNumber >> 8);
packet[1] = (uint8_t)(seqNumber++);
uint8_t i;
uint8_t sentence[] = {'T','E','S','T','T','E','S','T'};
for (i = 2; i < PAYLOAD_LENGTH; i++)
{
packet[i] = (uint8_t)sentence[i-2];
}
/* Set absolute TX time to utilize automatic power management */
time += PACKET_INTERVAL;
RF_cmdPropTx.startTime = time;
/* Send packet */
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
if (!(result & RF_EventLastCmdDone))
{
/* Error */
while(1);
}
PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
if (seqNumber > 0 && seqNumber % 20 == 0 ){
// RF_Stat rfStat;
txpowerlevelmode = (txpowerlevelmode+1)%(sizeof(txpowerlevel)/sizeof(txpowerlevel[0]));
// RF_cmdSetTxPower.txPower = txpowerlevel[txpowerlevelmode];
// rfStat = RF_runImmediateCmd(rfHandle,(uint32_t*) &RF_cmdSetTxPower);
RF_close(rfHandle);
RF_cmdPropRadioDivSetup.txPower = txpowerlevel[txpowerlevelmode];
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
}
}
}
Thank you
Julia
Hello Julia,
I tried to reproduce the issue by starting from a rfPacketTx example and overwriting with your txTaskFunction. Tx on my boards loops forever without stopping. I am not sure what is different in your case that is causing it to halt. I am using CC1310 launchpad.
Regards,
Prashanth
Hi Prashanth.
Is there maybe a setting in the smartRF.c file I am missing? I set the tx power to the 0x0041.
Or does it have to do with my receiver? I am using the cc1110 as receiver and the cc1310 as transmitter.
Hello Julia,
Since you said the Tx stopped, my guess is that it has nothing to do with the receiver. Just to make sure, can you turn off the receiver and try?
I am attaching the project that worked for me. Please compare this against your project.
Regards,
Prashanth
Hi Prashanth.
I tried pretty much everything but it does not want to work.
I am having problems with CCS installations, could that have something to do with it? It's my last hope. When I imported your project, a warning appeared saying:
Invalid project path: Include path not found (C:\ti\tirex-content\tirtos_cc13xx_cc26xx_2_20_00_06\products\cc13xxware_2_04_03_17272). rfPacketTx_CC1310_LAUNCHXL_TI_CC1310F128 pathentry Path Entry Problem
And when I try to install updates I am receiving error messages. But maybe this is the wrong thread.
I still don't understand why the code compiles nicely and the first 19 packets are send, and then it stops. When you tried it with the launchpad, were you able to see an increase in signal strength?
I am using the cc1310 5x5 chip if that helps. I made my own RF board.
When I try my normal code with infinite packets at one power level it is also working. :(
Cheers
Julia
Hello Julia,
Sorry to hear about the troubles you are facing. It is probably easier for me to switch to your version and try to reproduce the issue. Can you please tell me what version of CCS TI-RTOS and version of the compiler you are using? Did you happen to try this on a Launchpad?
Regards,
Prashanth
My CCS Version: 6.2.0.00050 and the CCS TI-RTOS 2.20.0.06.
I accidentally opened another thread, and one of your colleagues mentioned to try the easylink code. But looks so different, and I am not very talented in coding. But I guess I should try that too?
It's strange though because the code works for you . Should I try and change to a different receiver?
I have installed CCS v7 on a different computer, as I was not able to install version 6, due to error messages.
I am now trying to debug my code, but it tells me that one version of TI RTOS is missing. TIRTOSCC13XX_CC26XX' v2.20.0.06 is not currently installed and no compatible version is available. Please install this product or a compatible version.
I have installed version 2_20_00_06 and 2_21_00_06 and the error still comes up. :(
Hi Prasanth. Happy new year!
The RTOS version works now, I am using CCS v7 on my computer. So that's something.
I am still stuck with my transmitted packets though. It runs one loop and stops. I never mentioned I am working with 433MHz. I realised when I tried the smartRF studio with the launchpad and set the frequency to 433MHz only one power was available. But I am not sure if that matters, as I was able to use my single power level code with all different power levels available.
I was trying to work with the easylink example, but I could not get it to work at all. I'm not very talented in programming.
When you tried the code with your set up did it loop through all the power levels set in the code?
I don't really know what else to do :(
Cheers
Julia
Hi Prasanth,
We spent the last days on getting it running with no success, so I would like to give you all the details I have as a last try. I am using the cc1310 5x5 µC with the TI reference design. It is radiating with a TI antenna of 433MHz, which is connected with a micro SMA connector. My receiver is the cc1110 (433MHz) attached to a TrxEB evaluation board. I also have one CC1310 Launchpad available, but have deactivated the on-board antenna, to be able to use the included sma connector to attach the TI 433MHz antenna.
I would like to attach my code files to this blog. Can you let me know how to do it?
The first project would show the constant power level, which is running nicely. I can set the power level in the smartrf_setting.c file and I can use all the power levels from -10dBm to 10dBm and every time I change it I can see the RSSI of the receiving cc1110 in SmartRf studio changing. I also tried it with the cc1310 launchpad as receiver and it is also working. I know now, that the power levels are working and that the receiver and transmitter are talking to each other.
Now the stepwise increase of the power levels:
The code I sent you was not working, it only was able to use the powerlevel set in the smartrf_settings.c file. So whenever I changed the power in the code, it did not change the power level, the RSSI in smart RF studio did not rise or decrease. By moving the command RF_cmdPropRadioDivSetup.txPower = txpowerlevel[j];
out of the if statement, we can control the power within the code and not via the smartrf.c file. I am not sure why the .txpower cannot be controlled within the if statement, do you have any advice?
The problem still lies within the loop, I am not sure how to increase .txpower after e.g. 20 packets to the next power level in the array? if you have any ideas at how to modify the code then it would be very much appreciated. We tried to approach the code with some logical thinking and I guess we are close, but one small thing must be missing. It only loops once and gives up.
Would you have another look at the code from the project cc1310_5x5_pwrlevels?
Thank you
Julia
Thank you, Prashanth.
Lets see if this upload works. the zip file might be too big, otherwise I'll send you a link to a dropbox folder.20161213_RF_code_dynamic power ccs7.zip
Hello Julia,
Thank you for the zip file. I was able to test it, Since I do not have a CC1310 5x5 DK handy, I used CC1310 7x7 after switching to the correct board files.
I tried the rfPacketTx_C1310_5x5_pwrlevels project and did notice that it is getting stuck when the sequence number is 11. I noticed that the RF_close() is missing in the new project. Essentially, it was doing an RF_open on an already open handle and is getting stuck. Please note that when ever a change in the Tx power is required, one has to run RF_close() and do a RF_open() with new Tx power value. This was present in the code snippet you shared earlier on a different thread.
After adding RF_close(), I am now seeing that the loop runs with out halting.
if (seqNumber > 0 && seqNumber % 10 == 0 )
{
RF_close(rfHandle); //added
RF_cmdPropRadioDivSetup.txPower = txpowerlevel[j]; // added
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0); //added
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
}
Hi Prashanth.
It still stops after the 0009 packet number on smart Rf studio. If I comment the whole if statement the 2 set power levels continue alternating with no stopping.
// if (seqNumber > 0 && seqNumber % 10 == 0 )
// {
// RF_close(rfHandle); //added
// RF_cmdPropRadioDivSetup.txPower = txpowerlevel[j]; // added
// rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
// }
RF_cmdPropRadioDivSetup.txPower = txpowerlevel[j]; //
I have attached the picture of what I see in smart RF studio.
Kind regards
Julia
Hello Julia,
Please note that the RF frequency should also be set after closing and re-opening the RF, Please add this line to your code.
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
This is what is most likely causing the issue that you are seeing. Please add this line after RF_open and see if this fixes the problem.
I misunderstood earlier that your Tx program execution was getting stuck. Now I understand that it is the Rx reception is what is is halting.
Regards,
Prashanth
Thank you so much Prashanth.
It is finally working!!!! :) Thank you so much for your time!
This is the final bit of the code, if anyone is interested.
uint8_t j;
j = 0;
while(1)
{
/* Create packet with incrementing sequence number and random payload */
packet[0] = (uint8_t)(seqNumber >> 8);
packet[1] = (uint8_t)(seqNumber++);
uint8_t i;
uint8_t sentence[] = {'S','O','N','O','P','I','L','L','4'};
for (i = 2; i < PAYLOAD_LENGTH; i++)
{
packet[i] = (uint8_t)sentence[i-2];
}
/* Set absolute TX time to utilize automatic power management */
time += PACKET_INTERVAL;
RF_cmdPropTx.startTime = time;
/* Send packet */
RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
if (seqNumber > 0 && seqNumber % 20 == 0 )
{
if (++j >= sizeof(txpowerlevel)/sizeof(txpowerlevel[0])) j = 0;
RF_close(rfHandle); //added
RF_cmdPropRadioDivSetup.txPower = txpowerlevel[j]; // added
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); //added
}
}
}
Sorry, I have 2 more questions. Hope they won't take as long to answer though.
How do I add a pause after each power level increase? I would like to send again 20 packets, then pause for 2 minutes, and after that continue with the next power level. I tried the : void Task_sleep(UInt32 nticks) function and insert Task_sleep (500000); in the if statement. After the first loop the packet number jumps, as you can see below. It continues doing that after the next loop too. Why is that?
16:12:44.518 | 0000 | SONOPILL4 | -23
16:12:45.017 | 0001 | SONOPILL4 | -23
16:12:45.516 | 0002 | SONOPILL4 | -23
16:12:46.016 | 0003 | SONOPILL4 | -23
16:12:46.516 | 0004 | SONOPILL4 | -23
16:12:47.016 | 0005 | SONOPILL4 | -23
16:12:47.516 | 0006 | SONOPILL4 | -23
16:12:48.017 | 0007 | SONOPILL4 | -23
16:12:48.516 | 0008 | SONOPILL4 | -23
16:12:49.016 | 0009 | SONOPILL4 | -23
16:12:49.517 | 0010 | SONOPILL4 | -23
16:12:50.016 | 0011 | SONOPILL4 | -23
16:12:50.515 | 0012 | SONOPILL4 | -23
16:12:51.016 | 0013 | SONOPILL4 | -23
16:12:51.515 | 0014 | SONOPILL4 | -23
16:12:52.015 | 0015 | SONOPILL4 | -23
16:12:52.515 | 0016 | SONOPILL4 | -23
16:12:53.015 | 0017 | SONOPILL4 | -23
16:12:53.516 | 0018 | SONOPILL4 | -23
16:12:54.015 | 0019 | SONOPILL4 | -23
16:12:59.019 | 0020 | SONOPILL4 | -25
16:12:59.516 | 0030 | SONOPILL4 | -25
16:13:00.017 | 0031 | SONOPILL4 | -25
16:13:00.516 | 0032 | SONOPILL4 | -25
16:13:01.015 | 0033 | SONOPILL4 | -25
I would like to change the data rate to 500kbps. If I change the smartRF settings.c to this code below, would that give me the required data rate? Or is it only possible to use 50kbps?
rfc_CMD_PROP_RADIO_DIV_SETUP_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 = 0x64,
.symbolRate.preScale = 0x6,
.symbolRate.rateWord = 0x20000,
.rxBw = 0x24,
.preamConf.nPreamBytes = 0x4,
.preamConf.preamMode = 0x0,
.formatConf.nSwBits = 0x20,
.formatConf.bBitReversal = 0x0,
.formatConf.bMsbFirst = 0x1,
.formatConf.fecMode = 0x0,
.formatConf.whitenMode = 0x0,
.config.frontEndMode = 0x0,
.config.biasMode = 0x1,
.config.analogCfgMode = 0x0,
.config.bNoFsPowerUp = 0x0,
.txPower = 0x3DCB,
.pRegOverride = pOverrides,
.centerFreq = 0x01B1,
.intFreq = 0x8000,
.loDivider = 0x0A,
Kind regards
Julia
Hello Julia,
1. On the first question it is not clear to me what you are printing and what you mean by packet number jumps. Can you share the code if you think that will better help us understand.
2. For changing the data rate, please use SmartRF studio to identify the RF parameters that will work at 500Kbps. Change the deviation to 250kHz(modulation index of 1). Then increase the Rx filter BW until, Tx/Rx work successfully. Below settings worked for me.
Symbol Rate = 500kBaud
Deviation = 250 kHz
Rx Filter BW = 1243 kHz
Once you have it working in SmartRF studio, you can click on export code in command view and overwrite the smartrfsettigs.c file with the new parameters. This way you can update your settings to do 500kbps.
Regards,
Prashanth