完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本人使用CC1310来读取IO口的模拟电压,使用的开发板是CC1310DK_7XD,使用的例程为官方adcBufContinuous的例程。模拟引脚为DIO28,将该端口接GND后发现读到的数据并不是0,请问是什么原因。附上更改后的代码:
void conversionStartFxn(UArg arg0, UArg arg1) [ UART_Params uartParams; ADCBuf_Handle adcBuf; ADCBuf_Params adcBufParams; ADCBuf_Conversion continuousConversion; /* 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); //打开串口0 /* Set up an ADCBuf peripheral in ADCBuf_RECURRENCE_MODE_CONTINUOUS */ ADCBuf_Params_init(&adcBufParams); //ADC参数初始化 adcBufParams.callbackFxn = adcBufCallback; //ADC回调函数 *********************** adcBufParams.recurrenceMode = ADCBuf_RECURRENCE_MODE_CONTINUOUS; //连续输出模式 adcBufParams.returnMode = ADCBuf_RETURN_MODE_CALLBACK; //返回模式 立即返回 adcBufParams.samplingFrequency = 20; //采样频率为20 adcBuf = ADCBuf_open(Board_ADCBuf0, &adcBufParams); //打开ADC /* Configure the conversion struct */ //配置转换结构 continuousConversion.arg = NULL; //传递给回调函数的参数 continuousConversion.adcChannel = 2; //ADC采样的通道2******** continuousConversion.sampleBuffer = sampleBufferOne; //存储转换结果的缓冲区 continuousConversion.sampleBufferTwo = sampleBufferTwo; continuousConversion.samplesRequestedCount = ADCBUFFERSIZE; //要转换个返回的数量 100 if (!adcBuf)[ System_abort("adcBuf did not open correctlyn"); ] /* Start converting. */ if (ADCBuf_convert(adcBuf, &continuousConversion, 1) != //在一个通道上启动一组转换 ADCBuf_STATUS_SUCCESS) [ System_abort("Did not start conversion process correctlyn"); ] /* * Go to sleep in the foreground thread forever. The data will be collected * and transfered in the background thread */ Task_sleep(BIOS_WAIT_FOREVER); //任务休眠 后台运行AD转换 ] 回调函数 void adcBufCallback(ADCBuf_Handle handle, ADCBuf_Conversion *conversion, void *completedADCBuffer, uint32_t completedChannel) [ uint_fast16_t i; uint32_t valueBuf = 0; uint32_t avgBuf = 0; /* Adjust raw adc values and convert them to microvolts */ //调整原始ADC的值并且转换他们为微伏 ADCBuf_adjustRawValues(handle, completedADCBuffer, ADCBUFFERSIZE, //此函数调整原始ADC输出缓冲区,使得结果在同一个make的设备之间是可比较的。 completedChannel); ADCBuf_convertAdjustedToMicroVolts(handle, completedChannel, //该功能将原始ADC输出值转换为以微伏为单位的值。 completedADCBuffer, microVoltBuffer, ADCBUFFERSIZE); for (i = 0; i < ADCBUFFERSIZE; i++) [ valueBuf += microVoltBuffer; ] avgBuf = valueBuf/ADCBUFFERSIZE; /* Send out the data via UART */ UART_write(uart,&avgBuf,sizeof(avgBuf)); ] 配置文件CC1310DK_7XD.C /* * ========================== 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 #include /* ADC objects */ ADCBufCC26XX_Object adcBufCC26xxObjects[CC1310DK_7XD_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 adcBuf driver. * Comment out unused entries to save flash. * Dio and internal signal pairs are hardwired. Do not remap them in the table. You may reorder entire entries though. * The mapping of dio and internal signals is package dependent. */ const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[] = [ [Board_ALS_OUT, ADC_COMPB_IN_AUXIO7], [Board_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2], [Board_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0], [PIN_UNASSIGNED, ADC_COMPB_IN_VDDS] ]; const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1310DK_7XD_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 #include /* ADC objects */ ADCCC26XX_Object adcCC26xxObjects[CC1310DK_7XD_ADCCOUNT]; const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1310DK_7XD_ADCCOUNT] = [ [ .adcDIO = Board_ALS_OUT, .adcCompBInput = ADC_COMPB_IN_AUXIO7, .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_DIO30_ANALOG, .adcCompBInput = ADC_COMPB_IN_AUXIO0, .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]], [NULL, NULL, NULL], ]; /* * ========================== ADC end ========================================= */ 希望能有大哥指出小弟哪里出错了! |
|
相关推荐
2个回答
|
|
这个示例代码需要用到的light sensor在smartRF 06EB板上。
light sensor信号通过Board_ALS_OU(IOID_23引脚)输入到CC1310,在CC1310DK_7XD.C文件中有相关配置代码。 .adcDIO = Board_ALS_OUT, .adcCompBInput = ADC_COMPB_IN_AUXIO7, .refSource = ADCCC26XX_FIXED_REFERENCE, .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US, .inputScalingEnabled = true, .triggerSource = ADCCC26XX_TRIGGER_MANUAL 请检查你使用的引脚是否正确。 看你自己修改后的代码,你好像使用的是Board_DIO28_ANALOG和Board_DIO30_ANALOG两个引脚作为你测试是的AD信号输入引脚。 |
|
|
|
个人用户 发表于 2018-6-21 11:32 配置是对的,其实程序也是对的。只是读取到的数据自己又做了处理,结果自己看不懂了,太尴尬了。谢谢回复。结帖了。 |
|
|
|
只有小组成员才能发言,加入小组>>
358 浏览 1 评论
551 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
797 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
667 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1142 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
95浏览 29评论
385浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
268浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
217浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
75浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 04:14 , Processed in 0.846504 second(s), Total 79, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号