When customers use CC131 to develop products, they often encounter the scenario of switching rates. For example, they use 50Kbps transmission rate at this moment and 10Kbps transmission rate at the next moment. So how to effectively switch between the various rates? Here are two methods:
1. Use RF_control to switch the rate.
The RF_control function is described as follows:
/** * @brief Set RF control parameters *
@note Calling context : Task *
@param h Handle previously returned by RF_open()
@param ctrl Control codes
@param args Pointer to control arguments
indicates @return RF_Stat if API call was successfully completed.
*/
extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
The formal parameter h is rfhandle, which must be opened by RF_open before RF_control is executed. The formal parameter ctrl is a command, which is RF_CTRL_UPDATE_SETUP_CMD. This command description As follows:
/! * @brief Control code used by RF_control to update setup command * * Setting this control notifies RF that the setup command is to be updated, so that RF will take * proper actions when executing the next setup command. * Note the updated setup command will take effect in the next power up cycle when RF executes the * setup command. Prior to updating the setup command, user should make sure all pending commands * have completed. /
#define RF_CTRL_UPDATE_SETUP_CMD 1
That is, executing this command will make RF use the new parameters for the next data transmission and reception.
The specific usage is as follows. First, use the default 50Kbps rate to send a packet of data, then modify the RF_cmdPropRadioDivSetup related parameters to 10Kbps rate, then call RF_yield to turn off RF and start using the new parameters, and finally start a new data transmission using 10Kbps:
result = RF_runCmd(rfHandle, (RF_Op)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
if (!(result & RF_EventLastCmdDone))
{ while(1); }
HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = ( 1 << 25 );
RF_cmdPropRadioDivSetup. modulation.deviation = 0x4C;
RF_cmdPropRadioDivSetup.symbolRate.rateWord = 0x199A;
RF_cmdPropRadioDivSetup.rxBw = 0x23;
RF_cmdPropRadioDivSetup.pRegOverride = pOverrides_10K;
RF_control(rfHandle, RF_CTRL_UPDATE_SETUP_CMD, NULL);
RF_yield(rfHandle); //Force a power down using RF_yield() API. This will power down RF after all pending radio commands are complete .
HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = ( 1 << 25 );
result = RF_runCmd(rfHandle, (RF_Op)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);if (!(result & RF_EventLastCmdDone)){ while(1); }
The execution time of the red code in this test is about 18.8uS, which is very efficient. And when another board is set to receive at 10Kbps, the data can be received correctly, indicating that the rate switching is successful.
2. Use RF_close to switch the rate
This method is very simple. Turn off RF, then reinitialize RF, and then turn on RF to switch to the new rate. The specific usage is as follows: HWREG( GPIO_BASE + GPIO_O_DOUTSET31_0 ) = ( 1 << 25 );
RF_close(rfHandle);
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup_10K, &rfParams);
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
HWREG( GPIO_BASE + GPIO_O_DOUTCLR31_0 ) = ( 1 << 25 );
The execution time of the red code in this test is about 460uS, which is much lower than that of RF_control.
3. Use RFC_GPO3 to map:
As can be seen from the figure, GPO3 is pulled high when TX starts, and GPO3 is pulled low when TX ends. We map RFC_GPO3 to the LED pin
as follows: PINCC26XX_setMux(ledPinHandle, Board_LED3, PINCC26XX_MUX_RFC_GPO3);
Observe the time by observing the waveform of LED3, as shown below:
The low level in the figure indicates the time from the end of the last tx to the start of the next tx, which is about 1.5ms. The high level time indicates the time when sending at 10Kbps or 50Kbps .
|