CC2530 Setting the Transmit power

Source: Internet
Author: User
[CSharp]View plain copy 1. Relation of the value and power of Mac_radio_tx_power_default [CSharp]View Plain Copy [CSharp]View Plain Copy MAC_RADIO_DEFS.C [CSharp] View Plain copy const uint8 code macradiodefstxpwrbare[] =   {      3,  /* tramsmit power level of the first entry */       (uint8) (int8) -22, /* transmit power level of the  last entry */     /*   3 dbm */   0xf5,    /* characterized as  4.5 dBm in datasheet */      /*   2 dBm */   0xE5,   /*  characterized as  2.5 dbm in datasheet */     /*    1 dBm */   0xD5,   /* characterized as   1   dBm in datasheet */     /*   0  Dbm */   0xd5,   /* characterized as  1   dbm in  datasheet */     /*  -1 dBm */   0xC5,    /* characterized as -0.5 dBm in datasheet */     / *  -2 dbm */   0xb5,   /* characterized as - 1.5 dbm in datasheet */     /*  -3 dBm */    0xA5,   /* characterized as -3   dBm in  datasheet */     /*  -4 dBm */   0x95,    /* characterized as -4   dBm in datasheet */     /*  -5 dBm */   0x95,     /*  -6  dbm */   0x85,   /* characterized as -6   dbm in  datasheet */     /*  -7 dBm */   0x85,     /*  -8 dbm */   0x75,   /* characterized  as -8   dBm in datasheet */     /*  -9  dBm */   0x75,     /* -10 dBm */    0x65,   /* characterized as -10  dbm in datasheet */      /* -11 dBm */   0x65,     /* -12  dBm */   0x55,   /* characterized as -12   dbm in datasheet */     /* -13 dbm */   0x55,      /* -14 dbm */   0x45,   /* characterized as - 14  dbm in datasheet */     /* -15 dBm */    0x45,     /* -16 dBm */   0x35,    /* characterized as -16  dbm in datasheet */     /*  -17 dBm */   0x35,     /* -18 dBm */    0x25,   /* characterized as -18  dBm in  datasheet */     /* -19 dBm */   0x25,      /* -20 dBm */   0x15,   /* characterized as  -20  dbm in datasheet */     /* -21 dBm */    0x15,     /* -22 dBm */   0x05    /*  characterized as -22  dbm in datasheet */  };   #endif   


2. Locate the Macradiosettxpower function (set the Power function) in mac_radio.c, and copy the details as follows:[CSharp] View plain copy #ifndef  HAL_MAC_USE_REGISTER_POWER_VALUES         Mac_internal_ Api void macradiosettxpower (uint8 txpower)    {     halintstate_t   s;   #if  defined mac_runtime_cc2591 | |  defined MAC_RUNTIME_CC2590     const uint8 code *ptable =  macRadioDefsTxPwrTables[macRadioDefsRefTableId >> 4];   #elif  defined  hal_pa_lna | |  defined HAL_PA_LNA_CC2590     const uint8 code *ptable =  macRadioDefsTxPwrTables[0];   #else      const uint8 code * ptable = macradiodefstxpwrbare;        //The table contains Txpower setting values, Assign the first address of the table to the pointer ptable,        //macradiodefstxpwrbare[] defined in MAC_RADIO_DEFS.C     #endif    &NBSP;&NBsp       if  ((int8) txpower >  (int8) ptable[mac_radio_defs_tbl_txpwr_ First_entry])      {              txpower = ptable[mac_radio_defs_tbl_txpwr_first_entry];//Send Power limit value      }      else if  ((int8) txpower <  (int8) ptable[mac_radio_defs_tbl_txpwr_last_ ENTRY])      {             txpower  = ptable[mac_radio_defs_tbl_txpwr_last_entry];//transmit power lower value      }             hal_enter_critical_section (s);         {        uint8 index = ptable[mac_radio_defs_tbl_txpwr_first_entry]  - txPower         + MAC_RADIO_DEFS_TBL_TXPWR_ENTRIES;           reqTxPower = pTable[index];     }        //by calculating the conversion table index, get the transmit power value, assign it to reqtxpower,        // function Macradioupdatetxpower for update transmit power         hal_exit_critical_section (s);            macradioupdatetxpower ();  }     #else           mac_internal_api void macradiosettxpower (uint8 txpower)     {//Direct access to reqtxpower     halIntState_t  s;             hal_enter_critical_section (s);     reqTxPower = txPower;      hal_exit_critical_section (s);             Macradioupdatetxpower ();  }             Here's a look at MacradioupdatetxpoThe function body of the WER function is as follows:         mac_internal_api void macradioupdatetxpower (void)    {     halIntState_t  s;            hal_enter_critical_section (s);//Enter the critical area      if  (reqtxpower !=  Macphytxpower)//macphytxpower is the current actual transmit power      {             if  (!macrxoutgoingackflag && ! Mac_tx_is_physically_active ())           //The transmit power cannot be changed when a sending task is in progress.           //When the current send task finishes, the function is called again to send power settings.        {                  macPhyTxPower = reqTxPower;         mac_ Radio_set_tx_power (macphytxpower);//Set register txpower to macphytxpower, i.e. reqtxpower &nbsp     }     }     hal_exit_critical_section (s);//leave the critical area   }  [CSharp]View plain copy 3. Default definition (MAC_RADIO_DEFS.H)[CSharp]View Plain copy #define Mac_radio_channel_default//2440hz #define Mac_radio_tx_power_default 0x32
4. Assign operation to default value (Mac_radio. C[CSharp]View plain copy mac_internal_api void Macradioinit (void) {/* variable initialization for this module */Reqchan     Nel = mac_radio_channel_default;     Macphychannel = Mac_radio_channel_default;     Reqtxpower = Mac_radio_tx_power_default;   Macphytxpower = Mac_radio_tx_power_default; }

Description of Txpower in Cc2530datasheet




Setup process

#define Mac_radio_tx_power_default 0x32


Macphytxpower = Mac_radio_tx_power_default;

Mac_radio_set_tx_power (Macphytxpower);


Feedback from TI Employees:

Set to 0xf5 is the largest. (My understanding of the corresponding data in the Macradiodefstxpwrbare is the empirical value that TI has been tested for, some special values.) The range of values is 7-bit, the data between 0x05~0xf5 is meaningful, 0x32 between -17~-18dbm)

The latest version of the protocol stack does not already have this variable.

The configuration of the power, generally when the protocol stack initialization will be assigned to the configuration, if the program needs to modify the transmission power, you can also call this function directly


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.