设置发射功率

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

设置发射功率:

CC2530 设置RF的发送功率寄存器为TXPOWER,全局搜索一下可以看到以下代码

1.#define MAC_RADIO_SET_PAN_COORDINATOR(b) st( FRMFILT0 = (FRMFIL

T0 & ~PAN_COORDINATOR) | (PAN_COORDINATOR * (b!=0)); )

2.#define MAC_RADIO_SET_CHANNEL(x) st( FREQCTRL = FREQ_24

05MHZ + 5 * ((x) - 11); )

3.#define MAC_RADIO_SET_TX_POWER(x) st( TXPOWER = x; )

nt>

4.

5.#define MAC_RADIO_SET_PAN_ID(x) st( PAN_ID0 = (x) & 0x

FF; PAN_ID1 = (x) >> 8; )

6.#define MAC_RADIO_SET_SHORT_ADDR(x) st( SHORT_ADDR0 = (x)

& 0xFF; SHORT_ADDR1 = (x) >> 8; )

继续跟踪MAC_RADIO_SET_TX_POWER

/********************************************************************************** ****************

1.* @fn macRadioUpdateTxPower

2.*

3.* @brief Update the radio's transmit power if a new power level has be

en requested

4.*

5.* @param reqTxPower - file scope variable that holds the last request

power level

6.* macPhyTxPower - global variable that holds radio's set power

level

7.*

8.* @return none

9.****************************************************************************

**********************

10.*/

11.MAC_INTERNAL_API void macRadioUpdateTxPower(void)

12.{

13. halIntState_t s;

14.

15./*

16. * If the requested power setting is different from the actual radio sett

ing,

17. * attempt to udpate to the new power setting.

18. */

19. HAL_ENTER_CRITICAL_SECTION(s);

20.if (reqTxPower != macPhyTxPower)

21. {

22./*

23. * Radio power cannot be updated when the radio is physically transmitt

ing.

24. * If there is a possibility radio is transmitting, do not change the p

ower

25. * setting. This function will be called again after the current trans

mit

26. * completes.

27. */

28.if (!macRxOutgoingAckFlag && !MAC_TX_IS_PHYSICALLY_ACTIVE())

29. {

30./*

31. * Set new power level; update the shadow value and write

32. * the new value to the radio hardware.

33. */

34. macPhyTxPower = reqTxPower;

35. MAC_RADIO_SET_TX_POWER(macPhyTxPower);

36. }

37. }

38. HAL_EXIT_CRITICAL_SECTION(s);

39.}

在这里我们可以看到TXPOWER的设置值实际上应该是reqTxOower,让我看一下reqTxOower在哪里设置吧,继续跟踪可以发现reqTxPower在函数MAC_INTERNAL_API uint8 macRadioSetTxPower(uint8 txPower)中得到更新,一路跟踪下去可以在函数uint8 MAC_MlmeSetReq(uint8 pibAttribute, void *pValue)看到以下代码

case MAC_PHY_TRANSMIT_POWER:

1./* Legacy transmit power attribute */

2.#if !defined HAL_MAC_USE_REGISTER_POWER_VALUES && \

3. !defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590

4./* Legacy transmit power attribute value for CC2530 alone,

5. * or runtime selection support build means a negative absolute value.

6. * However, when used as register power values or

7. * with HAL_PA_LNAxxx definition (without runtime selection)

8. * the attribute value is not a negative absolute value. */

9. macPib.phyTransmitPower = (uint8)(-(int8)macPib.phyTransmitPower);

10.#endif /* !defined HAL_MAC_USE_REGISTER_POWER_VALUES && ... */

11./* pass through to next case -- do not break*/

12.

13.#endif /* MAC_OBSOLETE_PHY_TRANSMIT_POWER */

相关文档
最新文档