#include <airturbo/blower/blower_adc.h> //#define ADCBUFFERSIZE500 ADCBuf_Handle adcbuf; ADCBuf_Conversion conversion = {0}; uint16_t sampleBufferOne[ADCBUFFERSIZE]; //uint16_t sampleBufferTwo[ADCBUFFERSIZE]; uint32_t microvoltBuffer[ADCBUFFERSIZE]; //uint32_t buffersCompletedCounter = 0; // ADCBuf callback function void adcBufCallbackFxn(ADCBuf_Handle handle, ADCBuf_Conversion *conversion,void *buffer, uint32_t channel); extern void adcbuf_init(void) {ADCBuf_Params params;ADCBufCC26XX_ParamsExtension customParams;ADCBuf_init();ADCBuf_Params_init(¶ms);params.returnMode = ADCBuf_RETURN_MODE_CALLBACK;params.recurrenceMode = ADCBuf_RECURRENCE_MODE_ONE_SHOT;params.callbackFxn = adcBufCallbackFxn;params.samplingFrequency = 100000;customParams.samplingDuration= ADCBufCC26XX_SAMPLING_DURATION_2P7_US;customParams.refSource= ADCBufCC26XX_FIXED_REFERENCE;customParams.samplingMode= ADCBufCC26XX_SAMPING_MODE_SYNCHRONOUS;customParams.inputScalingEnabled = true;params.custom = &customParams;adcbuf = ADCBuf_open(Board_ADCBUF0, ¶ms);conversion.adcChannel = Board_ADCBUF0CHANNEL7;conversion.sampleBuffer = sampleBufferOne;//conversion.sampleBufferTwo = sampleBufferTwo;conversion.samplesRequestedCount = ADCBUFFERSIZE; } extern void adcbuf_convert(void) {if (ADCBuf_convert(adcbuf, &conversion, 1) != ADCBuf_STATUS_SUCCESS){// ADCBuf_convert() failed} } extern void adcbuf_convertCancel(void) {if (ADCBuf_convertCancel(adcbuf)!= ADCBuf_STATUS_SUCCESS){// ADCBuf_convert() failed} } void adcBufCallbackFxn(ADCBuf_Handle handle, ADCBuf_Conversion *conversion,void *buffer, uint32_t channel) {//malloc();// Adjust raw ADC values and convert them to microvoltsADCBuf_adjustRawValues(handle, buffer, ADCBUFFERSIZE,channel);ADCBuf_convertAdjustedToMicroVolts(handle, channel,buffer, microvoltBuffer, ADCBUFFERSIZE);/* for(int i = 0; i < ADCBUFFERSIZE ; i++){Log_info2("microvoltBuffer[%d]:%u ",i,(unsigned int)microvoltBuffer[i]);}*/Log_info0("ADC DONE"); }
我根据CC2640R2F的官方例程编写了ADC连续采样的代码,我的要求是在5ms内采500个信号,ADC的采样频率设置为100000,缓冲区的信号个数为500,编译成功系统可以运行,但蓝牙掉线,当我将采集个数改成300后,系统和蓝牙都可以正常运行,有没有办法能够既能够让蓝牙正常运行,系统也能正常运行
Viki Shi:
怀疑是内存不够导致的,参考一下这边的方法追踪是否为heap的问题:dev.ti.com/…/debugging-index.html
user6359397:
回复 Viki Shi:
谢谢你的回复。确实是内存不够导致的,更改后的ADC的缓冲区用malloc申请的,bl5的project_zero的PZ_TASK_STACK_SIZE 从2048改成了1024程序可以正常运行了,但这修改了程序的默认参数,我认为这是不稳定的,除此之外还有其他的解决办法吗?
Viki Shi:
回复 user6359397:
内存不够其实没有多好的办法,建议按照此文档增加RAM:https://www.ti.com/lit/an/swra537a/swra537a.pdf 如果还是不够,建议换用CC26X2
user6359397:
回复 Viki Shi:
我仔细想了想,我一开始申请了1K的ADC缓冲区存放在静态空间的时候,SRAM显示占用了13041kb(总:17408KB),明明还有将近4K空间富于,可为什么蓝牙确无法连接了,4K的空间应该足以支撑蓝牙的使用了吧?
user6359397:
回复 Viki Shi:
谢谢你的回复,我们用的是BLE5,应该可以决定更换BLE版本或更换芯片,有好的推荐吗?拜托了
Viki Shi:
回复 user6359397:
推荐CC2642/CC2652,SDK目前最新4.20:www.ti.com/…/SIMPLELINK-CC13X2-26X2-SDK
user6359397:
回复 Viki Shi:
十分感谢你的帮助!
Viki Shi:
回复 user6359397:
不客气,感谢您对TI产品的关注