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.

CC2650 的heartrate 例程里面有个电池服务,好像可以不需要外部adc引脚就可以直接读取电池电压

static uint8_t battMeasure(void)
{
  uint32_t percent;
  

  // Call measurement setup callback
  if (battServiceSetupCB != NULL)
  {
    battServiceSetupCB();
  }

  // Read the battery voltage (V), only the first 12 bits
  percent = AONBatMonBatteryVoltageGet();
  
  
  // Convert to from V to mV to avoid fractions.
  // Fractional part is in the lower 8 bits thus converting is done as follows:
  // (1/256)/(1/1000) = 1000/256 = 125/32
  // This is done most effectively by multiplying by 125 and then shifting
  // 5 bits to the right.
  percent = (percent * 125) >> 5;
  // Convert to percentage of maximum voltage.
  percent = ((percent* 100) / battMaxLevel);

  // Call measurement teardown callback
  if (battServiceTeardownCB != NULL)
  {
    battServiceTeardownCB();
  }

  return percent;
}

代码如上,

AONBatMonBatteryVoltageGet 这个函数接口是怎样获取到电池电压的?
  • //*****************************************************************************
    //
    //! \brief Get the battery monitor measurement.
    //!
    //! This function will return the current battery monitor measurement.
    //! The battery voltage measurements are updated every cycle.
    //!
    //! \note The returned value is NOT sign-extended!
    //!
    //! \note Use the function \ref AONBatMonNewBatteryMeasureReady() to test for
    //! a change in measurement.
    //!
    //! \return Returns the current battery monitor value of the battery voltage
    //! measurement in a <int.frac> format size <3.8> in units of volt.
    //!
    //! \sa AONBatMonNewBatteryMeasureReady()
    //
    //*****************************************************************************
    __STATIC_INLINE uint32_t
    AONBatMonBatteryVoltageGet(void)
    {
        uint32_t ui32CurrentBattery;
    
        ui32CurrentBattery = HWREG(AON_BATMON_BASE + AON_BATMON_O_BAT);
    
        //
        // Return the current battery voltage measurement.
        //
        return (ui32CurrentBattery >> AON_BATMON_BAT_FRAC_S);
    }
    

  • 这里涉及到的寄存器操作请看:software-dl.ti.com/.../AON_BATMON.html
  • 硬件上任何处理都不做就可以读出电池电压么?
  • 是的,AON_BATMON 是always on battery monitor模块,不停采集电压并更新,然后把数值写入相应的寄存器。用户只要读取即可