cc1310的ADC配置问题
自己在看TI提供的官方例程adcbufcontinuous。然后有两个问题
1.在程序中看到一个配置引脚,如下
PIN_Config AlsPinTable[] =
{
Board_ALS_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* Turn on ALS power */
PIN_TERMINATE /* Terminate list */
};
备注是光传感器,这个引脚应该是传感器的模拟信号输出引脚。那这个引脚对于CC1310来说引脚应该是模拟输入,但是这里为什么配置的是推拉输出?
2.程序有一个地方是设置ADC的通道。
continuousConversion.adcChannel = Board_ADCBufChannel0;
这个跟引脚应该是对应的,我在官网的数据手册中并没有找到通道和引脚的对应关系,不知道能否提供一个有通道引脚对应的数据手册链接?
以上两个问题希望能有大哥给解释一下。谢谢。
Board_ALS_PWR 引脚并不是AD的模拟输入引脚,而是GPIO输出,用来Turn on the power to the ambient light sensor
代码中的注释有说明
/*
* The CC2650DK_7ID and CC1310DK_7XD measure an ambient light sensor in this example.
* It is not powered by default to avoid high current consumption in other examples.
* The code below turns on the power to the sensor.
*/
恩,我把那个更改了,我看到输入引脚设置的状态没有模拟输入,这个该如何设置呢?
第二个问题已经解决了,在头文件里有解释:
* | DIO | CC26xx 7x7 AUXIO CompBInput | CC13xx 7x7 AUXIO CompBInput | CC26xx 5x5 AUXIO CompBInput | CC13xx 5x5 AUXIO CompBInput | CC26xx 4x4 AUXIO CompBInput | CC13xx 4x4 AUXIO CompBInput
* |--------|-------------------------------|-------------------------------|-------------------------------|-------------------------------|-------------------------------|-----------------------------
* | 0 | No | No | No | No | No | No
* | 1 | No | No | No | No | No | No
* | 2 | No | No | No | No | No | No
* | 3 | No | No | No | No | No | No
* | 4 | No | No | No | No | No | No
* | 5 | No | No | No | No | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7
* | 6 | No | No | No | No | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6
* | 7 | No | No | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5
* | 8 | No | No | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4
* | 9 | No | No | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3
* | 10 | No | No | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4 | No | No
* | 11 | No | No | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3 | No | No
* | 12 | No | No | ADC_COMPB_IN_AUXIO2 | ADC_COMPB_IN_AUXIO2 | No | No
* | 13 | No | No | ADC_COMPB_IN_AUXIO1 | ADC_COMPB_IN_AUXIO1 | No | No
* | 14 | No | No | ADC_COMPB_IN_AUXIO0 | ADC_COMPB_IN_AUXIO0 | No | No
* | 15-22 | No | No | No | No | No | No
* | 23 | ADC_COMPB_IN_AUXIO7 | ADC_COMPB_IN_AUXIO7 | No | No | No | No
* | 24 | ADC_COMPB_IN_AUXIO6 | ADC_COMPB_IN_AUXIO6 | No | No | No | No
* | 25 | ADC_COMPB_IN_AUXIO5 | ADC_COMPB_IN_AUXIO5 | No | No | No | No
* | 26 | ADC_COMPB_IN_AUXIO4 | ADC_COMPB_IN_AUXIO4 | No | No | No | No
* | 27 | ADC_COMPB_IN_AUXIO3 | ADC_COMPB_IN_AUXIO3 | No | No | No | No
* | 28 | ADC_COMPB_IN_AUXIO2 | ADC_COMPB_IN_AUXIO2 | No | No | No | No
* | 29 | ADC_COMPB_IN_AUXIO1 | ADC_COMPB_IN_AUXIO1 | No | No | No | No
* | 30 | ADC_COMPB_IN_AUXIO0 | ADC_COMPB_IN_AUXIO0 | No | No | No
头文件是ADCBufCC26XX.H
嗯,示例代码中的注释和说明还是很全面的。
但是引脚配置的问题还是没有解决,我在官方的资料上看到它的输入引脚配置的模式有四种
input mode(detached,hysteresis,pullup,pulldown)。这几个那个可以作为模拟输入呢?
这些都是针对GPIO的设置
在示例工程中的CC1310_LAUNCHXL.c文件中,有关于ADC相关引脚、参考源、采样时间、触发源等的设置
/*
* ========================== ADCBuf begin =========================================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(ADCBuf_config, ".const:ADCBuf_config")
#pragma DATA_SECTION(adcBufCC26xxHWAttrs, ".const:adcBufCC26xxHWAttrs")
#pragma DATA_SECTION(ADCBufCC26XX_adcChannelLut, ".const:ADCBufCC26XX_adcChannelLut")
#endif
/* Include drivers */
#include <ti/drivers/ADCBuf.h>
#include <ti/drivers/adcbuf/ADCBufCC26XX.h>
/* ADC objects */
ADCBufCC26XX_Object adcBufCC26xxObjects[CC1310_LAUNCHXL_ADCBufCOUNT];
/*
* This table converts a virtual adc channel into a dio and internal analogue input signal.
* This table is necessary for the functioning of the adc and adcBuf drivers.
* Comment out unused entries.
* Dio and internal signal pairs are hardwired. Do not remap them in the table.
* The mapping of dio and internal signals is package dependent. Make sure you copied the
* correct table from an example board file.
*/
const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[] = {
{PIN_UNASSIGNED, ADC_COMPB_IN_VDDS},
{PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL},
{PIN_UNASSIGNED, ADC_COMPB_IN_VSS},
{Board_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
{Board_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
{Board_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
{Board_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
{Board_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
{Board_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
{Board_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
{Board_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0},
};
const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1310_LAUNCHXL_ADCBufCOUNT] = {
{
.intPriority = ~0,
.swiPriority = 0,
.adcChannelLut = ADCBufCC26XX_adcChannelLut,
.gpTimerUnit = Board_GPTIMER0A,
.gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
}
};
const ADCBuf_Config ADCBuf_config[] = {
{&ADCBufCC26XX_fxnTable, &adcBufCC26xxObjects[0], &adcBufCC26xxHWAttrs[0]},
{NULL, NULL, NULL},
};
/*
* ========================== ADCBuf end =========================================
*/
/*
* ========================== ADC begin =========================================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(ADC_config, ".const:ADC_config")
#pragma DATA_SECTION(adcCC26xxHWAttrs, ".const:adcCC26xxHWAttrs")
#endif
/* Include drivers */
#include <ti/drivers/ADC.h>
#include <ti/drivers/adc/ADCCC26XX.h>
/* ADC objects */
ADCCC26XX_Object adcCC26xxObjects[CC1310_LAUNCHXL_ADCCOUNT];
const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCCOUNT] = {
{
.adcDIO = Board_DIO23_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO7,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO24_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO6,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO25_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO5,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO26_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO4,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO27_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO3,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO28_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO2,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO29_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO1,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = Board_DIO30_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO0,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = PIN_UNASSIGNED,
.adcCompBInput = ADC_COMPB_IN_DCOUPL,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = PIN_UNASSIGNED,
.adcCompBInput = ADC_COMPB_IN_VSS,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
},
{
.adcDIO = PIN_UNASSIGNED,
.adcCompBInput = ADC_COMPB_IN_VDDS,
.refSource = ADCCC26XX_FIXED_REFERENCE,
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true,
.triggerSource = ADCCC26XX_TRIGGER_MANUAL
}
};
const ADC_Config ADC_config[] = {
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[0], &adcCC26xxHWAttrs[0]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[1], &adcCC26xxHWAttrs[1]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[2], &adcCC26xxHWAttrs[2]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[3], &adcCC26xxHWAttrs[3]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[4], &adcCC26xxHWAttrs[4]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[5], &adcCC26xxHWAttrs[5]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[6], &adcCC26xxHWAttrs[6]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[7], &adcCC26xxHWAttrs[7]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[8], &adcCC26xxHWAttrs[8]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[9], &adcCC26xxHWAttrs[9]},
{&ADCCC26XX_fxnTable, &adcCC26xxObjects[10], &adcCC26xxHWAttrs[10]},
{NULL, NULL, NULL},
};
/*
* ========================== ADC end =========================================
*/
谢谢回复,我使用的是CC1310DK_7XD相关的设备。这个LAUNCHXL的代码也能适用?
CC1310DK_7XD和LAUNCHXL硬件上有不同(比如LED和按键的数量),所以代码是不能通用的。
CC1310DK_7XD的相关配置代码请查看CC1310DK_7XD.c
恩,刚看了CC1310DK_7XD.c的文件,修改了一些参数,但是还是AD读取的值还是不对,我把输入直接接GND,讲道理AD读出来的值应该很小,但是值取很大。我会继续追踪。