This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540: CC2540 PTM issue

Part Number: CC2540
Other Parts Discussed in Thread: CC2592

Our production equipment does not support signaling mode testing,unsignaling mode testing is too cumbersome for production.So I wanted to write a test code that would put CC2540 directly into "HCI_LE_Transmitter_Test  "mode,I see the following command, but I don't know how to write a code.Can you tell me how to write the following command as a code?

  • Hi Hank,

    Please take a look here: processors.wiki.ti.com/.../FCC_ETSI_Test

    Best Regards,
    R.M
  • The following figure,the TX power is 0dBm.How do I set TX power to 4dBm

  • Hi Hank,

    You can use the command HCIExt_SetTxPowerCmd(HCI_EXT_TX_POWER_4_DBM) to set the TX power to 4 dBm before you execute the HCI_EXT_ModemTestTxCmd command.

    Best Regards,
    R.M
  • Hi R.M

    I have tried your method, but it still has no effect. TheTX  output power is still 0dBm.Can you check the following code for me?

     HCI_EXT_SetTxPowerCmd(HCI_EXT_TX_POWER_4_DBM);

     HCI_EXT_ExtendRfRangeCmd();                   //配置PA是否中断CPU

     //End of configging PA(CC2592)

     P0SEL &= ~0x40;    //GPIO mode

     P0DIR &= ~BV(6);   //Input mode

     HCI_EXT_EndModemTestCmd();

     HCI_EXT_ModemTestTxCmd(HCI_EXT_TX_MODULATED_CARRIER,19);

     // Setup a delayed profile startup

     osal_set_event( simpleBLETaskId, START_DEVICE_EVT );

     // set a timer as 100ms

     osal_start_timerEx(simpleBLETaskId , SBP_SLEEP_EVT , SLEEP_MS);

    }

    See the attachment for the complete code

    void SimpleBLEPeripheral_Init( uint8 task_id )
    {
      simpleBLETaskId = task_id;
    
      // Setup the GAP
      VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL );
      
      // Setup the GAP Peripheral Role Profile
      {
         //device starts advertising upon initialization
         uint8 initial_advertising_enable = sys_config.advEnable;
    
        // By setting this to zero, the device will go into the waiting state after
        // being discoverable for 30.72 second, and will not being advertising again
        // until the enabler is set back to TRUE
        uint16 gapRole_AdvertOffTime = 0;
    _UPDATE_REQUEST;
        uint8 enable_update_request = DEFAULT_ENABLE
        uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
        uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
        uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;
        uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;
    
        // Set the GAP Role Parameters
      //  GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
        GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );
          
        uint8 AttDeviceNameLen = osal_strlen((char*)simpleBle_GetAttDeviceName());
        uint8 pSscanRspDataLen = ( 11 + AttDeviceNameLen);
        uint8 *pSscanRspData = osal_mem_alloc(pSscanRspDataLen);
        if(pSscanRspData)
        {
            uint8 index = 0;
            
            pSscanRspData[0] = AttDeviceNameLen + 1;
            pSscanRspData[1] = GAP_ADTYPE_LOCAL_NAME_COMPLETE;
            osal_memcpy(&pSscanRspData[2], simpleBle_GetAttDeviceName(), AttDeviceNameLen);
    
            index = 2 + AttDeviceNameLen;
            
            pSscanRspData[index+0] = 0x05;
            pSscanRspData[index+1] = GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE;
            pSscanRspData[index+2] = LO_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL );   // 100ms
            pSscanRspData[index+3] = HI_UINT16( DEFAULT_DESIRED_MIN_CONN_INTERVAL );
            pSscanRspData[index+4] = LO_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL );   // 1s
            pSscanRspData[index+5] = HI_UINT16( DEFAULT_DESIRED_MAX_CONN_INTERVAL );
    
            // Tx power level
            pSscanRspData[index+6] = 0x02;   // length of this data
            pSscanRspData[index+7] = GAP_ADTYPE_POWER_LEVEL;
            pSscanRspData[index+8] = 0;       // 0dBm    
    
            GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, pSscanRspDataLen, pSscanRspData );
    
            osal_mem_free(pSscanRspData);
        }
    
        GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( sys_config.advertData ), sys_config.advertData );
    
        GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
        GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
        GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
        GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
        GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );
      }
    
      // Set the GAP Characteristics
      GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, simpleBle_GetAttDeviceName() );
    
      {
         // 设置rssi 参数更新速率
         uint16 rssi_read_rate_1ms = 500; //一秒更新2次   
         GAPRole_SetParameter(GAPROLE_RSSI_READ_RATE, sizeof( uint16 ), &rssi_read_rate_1ms);
      }
        
      // Set advertising interval
      {
        uint16 advInt = DEFAULT_ADVERTISING_INTERVAL;
    
        //add by hubin for Set advertising interval,把0.625当6使用,否则总是溢出
        {
          advInt = ((1000/sys_config.advInterval)*10)/6;
        }
        //end add hubin
        
        GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
        GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
        GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advInt );
        GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advInt );
      }
    
      //下面是与配对相关的设置  
      // Setup the GAP Bond Manager
      {
        uint32 passkey = 0; // passkey "000000"
        uint8 pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
        uint8 mitm = TRUE;
        uint8 ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;  //显示密码, 以便主机输入配对的密码
    
        /*
        bonding就是把配对信息记录下来, 下次就不用配对了. 不bonding下次就还得配对.    
        所以我们从机这里把 bonding = FALSE 的后果就是, 主设备每次连接都必须输入密码
        而把  bonding = TRUE 后, 主设备只需第一次连接时输入密码, 后面断开后都不需要再次输入密码即可连接
        ---------------amomcu.com-------------------------    
        */
        uint8 bonding = FALSE;   
    
    //#if defined( BLE_BOND_PAIR )
        if(simpleBle_GetIfNeedPassword())
        {
            pairMode = GAPBOND_PAIRING_MODE_INITIATE;   //配对模式,置配成等待主机的配对请求
        }
        else
        {
            pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
        }    
    //#endif
    
        GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof ( uint32 ), &passkey );
        GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof ( uint8 ), &pairMode );
        GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof ( uint8 ), &mitm );
        GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof ( uint8 ), &ioCap );
        GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof ( uint8 ), &bonding );
      }
    
      // Initialize GATT attributes
      GGS_AddService( GATT_ALL_SERVICES );            // GAP
      GATTServApp_AddService( GATT_ALL_SERVICES );    // GATT attributes
      DevInfo_AddService();                           // Device Information Service
      SimpleProfile_AddService( GATT_ALL_SERVICES );  // Simple GATT Profile
    #if defined FEATURE_OAD
      VOID OADTarget_AddService();                    // OAD Profile
    #endif
    
      // Setup the SimpleProfile Characteristic Values
      {
        uint8 charValue1 = 1;
        uint8 charValue2 = 2;
        uint8 charValue3 = 3;
        uint8 charValue4 = 4;
        uint8 charValue5[SIMPLEPROFILE_CHAR5_LEN] = { 1, 2, 3, 4, 5 };
        uint8 charValue6[SIMPLEPROFILE_CHAR6_LEN] = { 1, 2, 3, 4, 5 };
        uint8 charValue7[SIMPLEPROFILE_CHAR7_LEN] = { 1, 2, 3, 4, 5 };
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR1, sizeof ( uint8 ), &charValue1 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR2, sizeof ( uint8 ), &charValue2 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR3, sizeof ( uint8 ), &charValue3 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof ( uint8 ), &charValue4 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN, charValue5 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR6, SIMPLEPROFILE_CHAR6_LEN, charValue6 );
        SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR7, SIMPLEPROFILE_CHAR7_LEN, charValue7 );
      }
    
      // Register callback with SimpleGATTprofile
      VOID SimpleProfile_RegisterAppCBs( &simpleBLEPeripheral_SimpleProfileCBs );
    
      // Enable clock divide on halt
      // This reduces active current while radio is active and CC254x MCU
      // is halted
      // 需要关闭的CLK自动分频,在初始化中加入HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_DISABLE_CLK_DIVIDE_ON_HALT )?  // 如果开启,会导致频率自动切换,DMA工作受到影响,小范围丢数。  
      // 这里把他关闭, 如果想降低功耗, 这个应该要开启的, 这里矛盾了  
      HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_DISABLE_CLK_DIVIDE_ON_HALT );
      //HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_ENABLE_CLK_DIVIDE_ON_HALT );
    
      //Begin to configging PA(CC2592)
      P1DIR |= BV(3);               //enable P1.3 as output,PA LNA_EN
      P1DIR |= BV(2);               //enable P1.2 as output,PA PA_EN
      P1DIR |= BV(1);               //enable P1.1 as output,PA HGM
      P1_1 = 1;                     //PA HGM enable ,about sch of 181
      
      RFC_OBS_CTRL0 = 0x68;
      RFC_OBS_CTRL1 = 0x6A;
      OBSSEL2 = 0xFB;
      OBSSEL3 = 0xFC;
    
      // 信号发射强度  dbm
      //HCI_EXT_SetTxPowerCmd(3 - sys_config.txPower);
      HCI_EXT_SetTxPowerCmd(HCI_EXT_TX_POWER_4_DBM);
      HCI_EXT_ExtendRfRangeCmd();                   //配置PA是否中断CPU
      //End of configging PA(CC2592)
    
      P0SEL &= ~0x40;    //GPIO mode
      P0DIR &= ~BV(6);   //Input mode
      HCI_EXT_EndModemTestCmd();
      HCI_EXT_ModemTestTxCmd(HCI_EXT_TX_MODULATED_CARRIER,19);
      // Setup a delayed profile startup
      osal_set_event( simpleBLETaskId, START_DEVICE_EVT );
      
      // set a timer as 100ms
      osal_start_timerEx(simpleBLETaskId , SBP_SLEEP_EVT , SLEEP_MS);
      
    }

  • Hi Hank,

    Since you have a setup with range extender (HCI_EXT_ExtendRfRangeCmd cmd) your maximum Tx output power that can be set with HCI_EXT_SetTxPowerCmd() is 0 dBm on CC2540. You can find more information on this in the TI_BLE_Vendor_Specific_HCI_Guide.pdf following the SDK.

    Best Regards,
    R.M