Part Number:LP-CC2652R7
int ModifyChannel(RF_Handle rfHandle,uint8_t channel){rfc_CMD_MODIFY_FS_t cmdModifyFs ={.commandNo = CMD_MODIFY_FS,.frequency = 2400 + channel,.fractFreq = 0};uint32_t start_tm = RF_getCurrentTime();RF_Stat status = RF_runImmediateCmd(rfHandle, (uint32_t*)&cmdModifyFs);if(RF_StatSuccess == status){uint32_t diff = RF_getCurrentTime() - start_tm;printf("Modify TO CHN:%d use %d us\n",channel,(diff+3)/4);}else{RF_printCmdStat(status);}return (int)status; }
我尝试了一下如上面的代码,系统老是返回:RF_StatInvalidParamsError,
想问一下这个命令执行前提是什么?是RF_postCmd RX或TX后异步执行?
希望您能指导一下。
Nick Sun:
您好,
我们需要一点时间查看这个问题,有结论后及时联系您。
,
Bright Z:
谢谢您的回复
RF_printCmdStat 仅仅是打印了枚举值
void RF_printCmdStat(RF_Stat result){if(result == RF_StatBusyError){printf("RF_StatBusyError\n");return ;}if(result == RF_StatRadioInactiveError) {printf("RF_StatRadioInactiveError\n");return ;}if(result == RF_StatCmdDoneError){printf("RF_StatCmdDoneError\n");return ;}if(result == RF_StatInvalidParamsError) {printf("RF_StatInvalidParamsError\n");return ;}if(result == RF_StatCmdEnded){printf("RF_StatCmdEnded\n");return ;}if(result == RF_StatError){printf("RF_StatError\n");return ;}if(result == RF_StatCmdDoneSuccess){printf("RF_StatCmdDoneSuccess\n");return ;}if(result == RF_StatCmdSch){printf("RF_StatCmdSch\n");return ;}if(result == RF_StatSuccess){printf("RF_StatSuccess\n");return ;}printf("Unknow:%d\n",result); }
,
Nick Sun:
您好,
您的这部分代码是有在相关SDK示例中吗?
,
Bright Z:
不是,都自己写的,
调用ModifyChannel 之前已确定radio 已经打开并 FS了。send & recv 都OK。
,
Nick Sun:
您好,
RF_cancelCmd返回RF_StatInvalidParamsError。
可以参考一下easylink_abort函数实现里对RF_cancelCmd参数的检查。
EasyLink_Status EasyLink_abort(void) {EasyLink_Status status = EasyLink_Status_Cmd_Error;if ( (!configured) || suspended){return EasyLink_Status_Config_Error;}//check an Async command is running, if not return successif (!EasyLink_CmdHandle_isValid(asyncCmdHndl)){return EasyLink_Status_Aborted;}//force abort (gracefull param set to 0)if (RF_cancelCmd(rfHandle, asyncCmdHndl, 0) == RF_StatSuccess){/* If command is cancelled immediately, callback may have set the cmd handle to invalid.* In that case, no need to pend.*/if (EasyLink_CmdHandle_isValid(asyncCmdHndl)){/* Wait for Command to complete */RF_EventMask result = RF_pendCmd(rfHandle, asyncCmdHndl, (RF_EventLastCmdDone |RF_EventCmdAborted | RF_EventCmdCancelled | RF_EventCmdStopped));if (result & RF_EventLastCmdDone){status = EasyLink_Status_Success;}}else{/* Command already cancelled */status = EasyLink_Status_Success;}}else{status = EasyLink_Status_Cmd_Error;}return status; }
,
Bright Z:
谢谢回复,
我的問题是为什么 RF_runImmediateCmd ( 命令号:CMD_MODIFY_FS) 总是返回 RF_StatInvalidParamsError
或如何正确使用 CMD_MODIFY_FS命令,最好有相关示例,谢谢
,
Nick Sun:
您好,
您可以参考 Radio Software Bundle (rflib) APIs 或 similar E2E threads,但没有具体的CMD_MODIFY_FS示例。
首先,您应确保在更改频率之前关闭无线电(RF_yield)。然后,CMD_MODIFY_FS命令本身仅用于较小的频率变化(几MHz)以保持PLL lock,所以channel更改不适用于这种情况。考虑到这个用例,我们认为应该使用CMD_FS,并使用RF_runCmd而不是RF_runImmediateCmd。