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.

MSP430F5529: ADC with DMA, unexpected values written to array

Part Number: MSP430F5529
Other Parts Discussed in Thread: MSP430WARE

I am trying to implement a round robin ADC scheme where 4 channels are continuously read in around robin and the values updated to an array using DMA. I have cobbled this together using examples from the MSP430ware driver library.

The round robin works as expected, with the expected values in the array when main() is permitted to terminate and the DMA is allowed to run on its own. If there are contents in main(), like a while(1) to perform some operation on this ADC data, the ADC values found in the array are always very low. 0 or near to zero where the expectation is around 1000. The values do change, so are being updated, just incorrectly.

I honestly don't understand why there are unexpected values being written to the array when the MCU is doing something; I would have an easier time understand no values or unchanging values.

Thanks in advance for any help.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "driverlib.h"
#include <dma.h>
volatile uint16_t adcDmaTarget[NUMDMAWORDS];
//*****************************************************************************
//
//Configure DMA
//
//*****************************************************************************
void configDma(void) {
DMA_enableRoundRobinPriority();
DMA_initParam dmaParam0 = {0};
dmaParam0.channelSelect = DMA_CHANNEL_0;
dmaParam0.transferModeSelect = DMA_TRANSFER_REPEATED_SINGLE;
dmaParam0.transferSize = NUMDMAWORDS;
dmaParam0.triggerSourceSelect = DMA_TRIGGERSOURCE_24;
dmaParam0.transferUnitSelect = DMA_SIZE_SRCWORD_DSTWORD;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void configAdc(void) {
//Enable A/D channel inputs
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,
GPIO_PIN0 |
GPIO_PIN1 |
GPIO_PIN2 |
GPIO_PIN3
);
//Initialize the ADC12_A Module
/*
* Base address of ADC12_A Module
* Use internal ADC12_A bit as sample/hold signal to start conversion
* USE MODOSC 5MHZ Digital Oscillator as clock source
* Use default clock divider of 1
*/
ADC12_A_init(ADC12_A_BASE,
ADC12_A_SAMPLEHOLDSOURCE_SC,
ADC12_A_CLOCKSOURCE_ACLK,
ADC12_A_CLOCKDIVIDER_1);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Hardy,

    Could you try to perform some operation to the array in the DMA interrupt? 

  • Stupid mistake...

    I was not incrementing the DMA source. OOPS! Changing NOCHANGE to INCREMENT fixed it up.

    Thank you.

    DMA_setSrcAddress(DMA_CHANNEL_0,
    ADC12_A_getMemoryAddressForDMA(ADC12_A_BASE, ADC12_A_MEMORY_0),
    DMA_DIRECTION_INCREMENT);

    DMA_setDstAddress(DMA_CHANNEL_0,
    (uint32_t)(uintptr_t)&adcDmaTarget,
    DMA_DIRECTION_INCREMENT);

**Attention** This is a public forum