这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » [分享] CC1310切换速率的办法

共4条 1/1 1 跳转至

[分享] CC1310切换速率的办法

工程师
2019-08-17 11:44:01     打赏

客户在使用CC131开发产品的过程中,经常会遇到切换速率的场景,比如此刻使用50Kbps速率传输,下一时刻使用10Kbps速率传输,那么如何有效的在各个速率之间切换,这里介绍两个办法:
一、使用RF_control来切换速率
RF_control函数说明如下:
/** * @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
@return RF_Stat indicates if API call was successfully completed.
*/
extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
其中形参h为rfhandle,必须RF_control执行之前由RF_open打开形参ctrl为命令,为RF_CTRL_UPDATE_SETUP_CMD,这个命令说明如下:
/! * @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
也就是执行这个命令会让RF使用新的参数来进行下一次数据收发。
具体使用方法如下,这里首先使用默认的50Kbps速率发送一包数据,然后修改RF_cmdPropRadioDivSetup相关参数为10Kbps速率,然后调用RF_yield将RF关闭并开始启用新的参数,最后开始使用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); }
这里测试标红部分代码的执行时间约为18.8uS,效率很高。而且用另一块板子设定在10Kbps速率接收,数据能够正确接收到,说明速率切换成功了。

二、使用RF_close来切换速率
这个方法很简答,将RF关闭,然后重新初始化RF,再打开RF,就切换到新的速率了,具体使用方法如下: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 );
这里测试标红部分代码的执行时间约为460uS,效率较RF_control相比低多了。

三、使用RFC_GPO3来映射:
由图中可以看到,当TX开始时GPO3拉高,当TX结束时GPO3拉低。我们将RFC_GPO3映射到LED引脚上,
如下:PINCC26XX_setMux(ledPinHandle, Board_LED3, PINCC26XX_MUX_RFC_GPO3);
通过观察LED3的波形来观察时间,如下图:
图中的低电平即表示上一次tx结束到下一次tx开始的时间,约为1.5ms,高电平的时间表示以10Kbps或者50Kbps发送时的时间。

 




工程师
2019-08-17 12:00:58     打赏
2楼

学习


工程师
2019-08-17 12:12:15     打赏
3楼

干货干货


工程师
2019-08-17 12:23:28     打赏
4楼

谢谢分享


共4条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]