Part Number:LAUNCHXL-CC1310
如何使用ADCBuf对多通道的电压值进行连续采样?
Kevin Qiu1:
ADCbuf无法对多个通道进行采样
,
user6336125:
就我我在回调函数里面这里操作会有问题吗?通过init和close来控制adc通道采样,在回调函数中切换采样通道
void adcBufCallback(ADCBuf_Handle handle, ADCBuf_Conversion *conversion,void *completedADCBuffer, uint32_t completedChannel) {/* Adjust raw ADC values and convert them to microvolts */ADCBuf_adjustRawValues(handle, completedADCBuffer, ADCBUFFERSIZE, completedChannel);ADCBuf_convertAdjustedToMicroVolts(handle, completedChannel, completedADCBuffer, microVoltBuffer, ADCBUFFERSIZE);//数据处理if(ADCBuf_STATUS_SUCCESS != ADCBuf_convertCancel(adcBuf)){//while(1);}//采样通道切换continuousConversion.arg = NULL;continuousConversion.sampleBuffer = sampleBufferOne;continuousConversion.sampleBufferTwo = sampleBufferTwo;continuousConversion.samplesRequestedCount = ADCBUFFERSIZE;switch(step){case 0:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL2;step = 1;break;case 1:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL3;step = 2;break;case 2:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL4;step = 3;break;case 3:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL5;step = 4;break;case 4:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL6;step = 5;break;case 5:continuousConversion.adcChannel = Board_ADCBUF0CHANNEL7;step = 6;break;case 6:continuousConversion.adcChannel = Board_ADCBUF0CHANNELVDDS;step = 0;break;}/* Start converting. */if (ADCBuf_convert(adcBuf, &continuousConversion, 1) !=ADCBuf_STATUS_SUCCESS) {/* Did not start conversion process correctly. */while(1);} }bool adc_init() {uint8_t i;if(adcBuf != NULL){return false;}/* 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 = 10000;adcBuf = ADCBuf_open(Board_ADCBUF0, &adcBufParams);/* Configure the conversion struct */continuousConversion.arg = NULL;continuousConversion.adcChannel = Board_ADCBUF0CHANNEL2;continuousConversion.sampleBuffer = sampleBufferOne;continuousConversion.sampleBufferTwo = sampleBufferTwo;continuousConversion.samplesRequestedCount = ADCBUFFERSIZE;if (adcBuf == NULL){return false;/* ADCBuf failed to open. *///while(1){}}/* Start converting. */if (ADCBuf_convert(adcBuf, &continuousConversion, 1) !=ADCBuf_STATUS_SUCCESS) {adc_close();return false;/* Did not start conversion process correctly. *///while(1){}}return true; }void adc_close() {ADCBufCC26XX_Object*object;if(adcBuf != NULL){/* Get the pointer to the object and hwAttrs*/object = adcBuf->object;/* Check if ADC is open and that no other transfer is in progress */while(!(object->conversionInProgress));if(ADCBuf_STATUS_SUCCESS != ADCBuf_convertCancel(adcBuf)){GPIO_write(Board_GPIO_LED1, ON);}ADCBuf_close(adcBuf);adcBuf = NULL;} }
,
Kevin Qiu1:
参考这里提到的几种方式:https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/955125/cc1310-sampling-3-channels-using-adcbuf
如果一定要使用ADCbuf,请记住每次只能采集一个通道