This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi Expert,
I use example project "adc12_max_freq_dma_LP_MSPM0G3507_nortos_ticlang" in sdk 2.2.0.5.
I change the ADC channels from 1 channel to 8 channels. I connect one channel to 3.3V and the other channels to ground. So, I can know if the adc result is correct or not.
I found the ADC data "gADCSamples" is wrong sometimes. The ADC result with 3.3V channel would "shift" to other ADC result. It seems that DMA doesn't move the data to data correctly.
Below is what I change.
in code, I change sample size from 1024 to 8.
#define ADC_SAMPLE_SIZE (8)
in sysconfig, I change below except enable adc channels.
/* * Copyright (c) 2021, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "ti_msp_dl_config.h" #define ADC_SAMPLE_SIZE (8) /* When FIFO is enabled 2 samples are compacted in a single word */ #define ADC_FIFO_SAMPLES (ADC_SAMPLE_SIZE >> 1) uint16_t gADCSamples[ADC_SAMPLE_SIZE]; volatile bool gCheckADC; int main(void) { SYSCFG_DL_init(); /* Configure DMA source, destination and size */ DL_DMA_setSrcAddr(DMA, DMA_CH0_CHAN_ID, (uint32_t) DL_ADC12_getFIFOAddress(ADC12_0_INST)); DL_DMA_setDestAddr(DMA, DMA_CH0_CHAN_ID, (uint32_t) &gADCSamples[0]); DL_DMA_setTransferSize(DMA, DMA_CH0_CHAN_ID, ADC_FIFO_SAMPLES); DL_DMA_enableChannel(DMA, DMA_CH0_CHAN_ID); /* Setup interrupts on device */ NVIC_EnableIRQ(ADC12_0_INST_INT_IRQN); gCheckADC = false; DL_ADC12_startConversion(ADC12_0_INST); while (false == gCheckADC) { __WFE(); } // __BKPT(0); while (1) { __WFI(); } } void ADC12_0_INST_IRQHandler(void) { switch (DL_ADC12_getPendingInterrupt(ADC12_0_INST)) { case DL_ADC12_IIDX_DMA_DONE: gCheckADC = true; break; default: break; } }
Any idea where I am wrong?
BR,
Frank
Hi Frank,
Can you confirm that you are sampling Channel 0 and that Channel 0 is fed the 3.3V while the other channels are fed from the ground? If that's the case, I would recommend first trying the original example (with the default values in SYSCONFIG & main file) and check if that works. If it does, I recommend changing the Conversion End Address from 7 to 10 and changing MEM7 to MEM10. Moreover, please consider the note from the 12.2.12.3 DMA and FIFO Operation section in the Userguide.
Best Regards,
Diego Abad