芯片用的是RHB (5-mm × 5-mm) Pinout 封装,ADC的引脚是接到DIO_10
ADC 初始化如下:
// Define name for ADC channel index
#define BATTERY_ADC 3
static ADC_Params params;
static ADC_Handle adcHandle;
void battery_init(void)
{
ADC_init();
ADC_Params_init(¶ms);
params.isProtected = true;
adcHandle = ADC_open(BATTERY_ADC, ¶ms);
}
uint32_t battery_capacity(void)
{
ADC_convert(adcHandle, &result);
MicroVolts = ADC_convertToMicroVolts(adcHandle, result);
return MicroVolts ;
}
测试ADC的读取是错误的,把BATTERY_ADC 改为2反而能正确读取,从表格上可知,DIO_7~DIO_14 都有ADC功能。
CC1310_LAUNCHXL.h 上ADC的管脚配置已经修改如下:
/* Analog capable DIOs */
#define CC1310_LAUNCHXL_DIO23_ANALOG IOID_7
#define CC1310_LAUNCHXL_DIO24_ANALOG IOID_8
#define CC1310_LAUNCHXL_DIO25_ANALOG IOID_9
#define CC1310_LAUNCHXL_DIO26_ANALOG IOID_10
#define CC1310_LAUNCHXL_DIO27_ANALOG IOID_11
#define CC1310_LAUNCHXL_DIO28_ANALOG IOID_12
#define CC1310_LAUNCHXL_DIO29_ANALOG IOID_13
#define CC1310_LAUNCHXL_DIO30_ANALOG IOID_14
我的问题是:
1. 将宏定义BATTERY_ADC改成2 ADC似乎是正确的,从手册上宏定义BATTERY_ADC改为2读取应该是DIO_9管脚的ADC才对!又或者是我理解错误?
2. 将宏定义BATTERY_ADC改成3 ADC数值读取的值错误,是能读取,但数值不正确。