TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1350 AD 采集

在不使用多线程的情况下在buffer模式下能否实现多通道采集

Viki Shi:

多线程跟ADC多通道无关,不论是单通道采集还是多通道采集,都是一个线程。推荐看一下这边的例程:http://dev.ti.com/tirex/explore/node?node=AC.rsUKsVvdCiKwydCQGYg__eCfARaV__LATEST

zhenzhe piao:

回复 Viki Shi:

但是adcbuffer连续测量只支持一个通道啊

Viki Shi:

回复 zhenzhe piao:

是的,CC1350支持多达8个adc channel,但是同一时刻只有一个通道能进行采样

zhenzhe piao:

回复 Viki Shi:

这个我知道。就是能不能切换测量通道
这是我根据buffer例程改的四通道的,但是uart只有第一个通道的数据,其他三个通道均为0
UART_Params uartParams;ADCBuf_Handle adcBuf;ADCBuf_Params adcBufParams;ADCBuf_Conversion continuousConversion[4];
/* Call driver init functions */ADCBuf_init();UART_init();
/* Create a UART with data processing off. */UART_Params_init(&uartParams);uartParams.writeDataMode = UART_DATA_BINARY;uartParams.writeMode = UART_MODE_CALLBACK;uartParams.writeCallback = uartCallback;uartParams.baudRate = 115200;uart = UART_open(Board_UART0, &uartParams);
/* Set up an ADCBuf peripheral in ADCBuf_RECURRENCE_MODE_CONTINUOUS */

int q;
for(q=0;q<3;q++){ADCBuf_Params_init(&adcBufParams);adcBufParams.callbackFxn = adcBufCallback;adcBufParams.recurrenceMode = ADCBuf_RECURRENCE_MODE_CONTINUOUS;adcBufParams.returnMode = ADCBuf_RETURN_MODE_CALLBACK;adcBufParams.samplingFrequency = 2;/* Create a UART with data processing off. *///uart = UART_open(Board_UART0, &uartParams);adcBuf = ADCBuf_open(Board_ADCBUF0, &adcBufParams);/* Configure the conversion struct */continuousConversion[q].arg = NULL;continuousConversion[q].adcChannel = q+2;continuousConversion[q].sampleBuffer = sampleBufferOne;continuousConversion[q].sampleBufferTwo = sampleBufferTwo;continuousConversion[q].samplesRequestedCount = ADCBUFFERSIZE/4;
if (adcBuf == NULL){/* ADCBuf failed to open. */while(1);}
/* Start converting. */if (ADCBuf_convert(adcBuf, &continuousConversion[q], 4) !=ADCBuf_STATUS_SUCCESS) {/* Did not start conversion process correctly. */while(1);}

}

Viki Shi:

回复 zhenzhe piao:

1、不同的channel要定义不同的buffer,以下语句需要改
continuousConversion[q].sampleBuffer = sampleBufferOne;
continuousConversion[q].sampleBufferTwo = sampleBufferTwo;

2、ADCBuf_RECURRENCE_MODE_CONTINUOUS模式下,会一直采样填充buffer,取消掉前一个再进行下一个channel的读取
#ADCBuf_RECURRENCE_MODE_CONTINUOUS conversion can only be terminated using ADCBuf_convertCancel().

zhenzhe piao:

回复 Viki Shi:

那我需要4个channel,那还需要定义8个buf么??

zhenzhe piao:

回复 Viki Shi:

刚接触CC1350,可以说的详细点么

Viki Shi:

回复 zhenzhe piao:

是,类似下面这样:

/* Configure the conversion struct */
continuousConversion.arg = NULL;
continuousConversion.adcChannel = Board_ADCBUF0CHANNEL0;
continuousConversion.sampleBuffer = sampleBufferOne;
continuousConversion.sampleBufferTwo = sampleBufferTwo;
continuousConversion.samplesRequestedCount = ADCBUFFERSIZE;..../* Configure the conversion struct */
continuousConversion2.arg = NULL;
continuousConversion2.adcChannel = Board_ADCBUF0CHANNEL1;
continuousConversion2.sampleBuffer = sampleBufferOne2;
continuousConversion2.sampleBufferTwo = sampleBufferTwo2;
continuousConversion2.samplesRequestedCount = ADCBUFFERSIZE;

zhenzhe piao:

回复 Viki Shi:

我根据你的提示更改代码但是读不出数据UART_Params uartParams;ADCBuf_Handle adcBuf;ADCBuf_Params adcBufParams;ADCBuf_Conversion continuousConversion[4];
/* Call driver init functions */ADCBuf_init();UART_init();
/* Create a UART with data processing off. */UART_Params_init(&uartParams);uartParams.writeDataMode = UART_DATA_BINARY;uartParams.writeMode = UART_MODE_CALLBACK;uartParams.writeCallback = uartCallback;uartParams.baudRate = 115200;uart = UART_open(Board_UART0, &uartParams);
/* Set up an ADCBuf peripheral in ADCBuf_RECURRENCE_MODE_CONTINUOUS */ADCBuf_Params_init(&adcBufParams);adcBufParams.callbackFxn = adcBufCallback;adcBufParams.recurrenceMode = ADCBuf_RECURRENCE_MODE_CONTINUOUS;adcBufParams.returnMode = ADCBuf_RETURN_MODE_CALLBACK;adcBufParams.samplingFrequency = 200;adcBuf = ADCBuf_open(Board_ADCBUF0, &adcBufParams);

/* Configure the conversion struct */continuousConversion[0].arg = NULL;continuousConversion[0].adcChannel = 2;continuousConversion[0].sampleBuffer = sampleBufferOne;continuousConversion[0].sampleBufferTwo = sampleBufferTwo;continuousConversion[0].samplesRequestedCount = ADCBUFFERSIZE/4;

continuousConversion[1].arg = NULL;continuousConversion[1].adcChannel = 3;continuousConversion[1].sampleBuffer = sampleBufferOne2;continuousConversion[1].sampleBufferTwo = sampleBufferTwo2;continuousConversion[1].samplesRequestedCount = ADCBUFFERSIZE/4;

continuousConversion[2].arg = NULL;continuousConversion[2].adcChannel = 4;continuousConversion[2].sampleBuffer = sampleBufferOne3;continuousConversion[2].sampleBufferTwo = sampleBufferTwo3;continuousConversion[2].samplesRequestedCount = ADCBUFFERSIZE/4;

continuousConversion[3].arg = NULL;continuousConversion[3].adcChannel = 5;continuousConversion[3].sampleBuffer = sampleBufferOne4;continuousConversion[3].sampleBufferTwo = sampleBufferTwo4;continuousConversion[3].samplesRequestedCount = ADCBUFFERSIZE/4;
if (adcBuf == NULL){/* ADCBuf failed to open. */while(1);}
/* Start converting. */if (ADCBuf_convert(adcBuf, &continuousConversion[4], 4) !=ADCBuf_STATUS_SUCCESS) {/* Did not start conversion process correctly. */while(1);}

如果将
if (ADCBuf_convert(adcBuf, &continuousConversion[4], 4) !=ADCBuf_STATUS_SUCCESS) {/* Did not start conversion process correctly. */while(1);}中的&continuousConversion[4]改为 &continuousConversion[0]、 &continuousConversion[1]、 &continuousConversion[2]、 &continuousConversion[3]
均只能读出单个通道的数据
这是为什么

Viki Shi:

回复 zhenzhe piao:

上文的第二点建议是否采纳?

赞(0)
未经允许不得转载:TI中文支持网 » CC1350 AD 采集
分享到: 更多 (0)