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.

CCS/EK-TM4C1294XL: adc sequencer 3 using udma

Part Number: EK-TM4C1294XL

Tool/software: Code Composer Studio

Hi Friends,

Iam working on ek-tm4c1294xl kit ,currently iam trying to integrate adc with udma iam attaching .iam having that it unable to tranfer data from buffer to destination .In this program iam trying print the data that i have captured in adc.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "driverlib/fpu.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/uart.h"
#include "driverlib/udma.h"
#include "utils/cpu_usage.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "utils/uartstdio.c"
#include "driverlib/adc.h"
#include "inc/hw_adc.h"
static int i;

#define MEM_BUFFER_SIZE 1024

#define UART_TXBUF_SIZE 256
#define UART_RXBUF_SIZE 256


//static uint32_t g_ui8TxBuf[UART_TXBUF_SIZE];
static uint32_t g_ui8RxBufA[UART_RXBUF_SIZE];
static uint32_t g_ui8RxBufB[UART_RXBUF_SIZE];


static uint32_t g_ui32uDMAErrCount = 0;


static uint32_t g_ui32BadISR = 0;

static uint32_t g_ui32RxBufACount = 0;
static uint32_t g_ui32RxBufBCount = 0;

uint32_t g_ui32SysClock;

#if defined(ewarm)
#pragma data_alignment=1024
uint8_t pui8ControlTable[1024];
#elif defined(ccs)
#pragma DATA_ALIGN(pui8ControlTable, 1024)
uint8_t pui8ControlTable[1024];
#else
uint8_t pui8ControlTable[1024] __attribute__ ((aligned(1024)));
#endif


#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

void
uDMAErrorHandler(void)
{
uint32_t ui32Status;


ui32Status = uDMAErrorStatusGet();

if(ui32Status)
{
uDMAErrorStatusClear();
g_ui32uDMAErrCount++;
}
}


void ADCseq0Handler()

{
uint_fast16_t ui16Idx;
uint32_t ui32Status;
uint32_t ui32Mode;
for(ui16Idx = 0; ui16Idx < UART_TXBUF_SIZE; ui16Idx++)
{
UARTprintf("printing forom receiver side");
UARTprintf("hello receiver %d",g_ui8RxBufA[ui16Idx] );
}

ADCIntClearEx(ADC0_BASE, ADC_INT_DMA_SS0 | ADC_INT_SS0);

if (uDMAChannelModeGet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT) == UDMA_MODE_STOP) {
// found the full buffer

// re-set up a DMA transfer to the buffer

uDMAChannelTransferSet((UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT), UDMA_MODE_PINGPONG, (void *)(ADC0_BASE + ADC_O_SSFIFO0), g_ui8RxBufA, sizeof(g_ui8RxBufA));

}

if (uDMAChannelModeGet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT) == UDMA_MODE_STOP) {
// found the full buffer

// re-set up a DMA transfer to the buffer
uDMAChannelTransferSet((UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT), UDMA_MODE_PINGPONG, (void *)(ADC0_BASE + ADC_O_SSFIFO0), g_ui8RxBufB, sizeof(g_ui8RxBufB));
}
/* if(!uDMAChannelIsEnabled(UDMA_CHANNEL_ADC0))
{

uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
UDMA_MODE_BASIC, g_ui8TxBuf,
(void *)( ADC0_BASE + ADC_O_SSFIFO0),
sizeof(g_ui8TxBuf));
uDMAChannelEnable(UDMA_CHANNEL_ADC0);
}*/


}


void
InitUART1Transfer(void)


{
uint32_t div;

SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0);
ADCClockConfigSet(ADC0_BASE,ADC_CLOCK_SRC_PLL,ADC_CLOCK_RATE_FULL);
ADCSequenceConfigure(ADC0_BASE, 0 /*SS0*/, ADC_TRIGGER_ALWAYS, 3 /*priority*/); // SS0-SS3 priorities must always be different
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 0, ADC_CTL_TS); // ADC_CTL_TS = read temp sensor
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 2, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 3, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 4, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 5, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 6, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 7, ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE); // ADC_CTL_IE fires every 8 samples
ADCSequenceEnable(ADC0_BASE, 0);
ADCSequenceDMAEnable(ADC0_BASE, 0);
uDMAChannelAttributeDisable(UDMA_CHANNEL_ADC0,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
UDMA_ARB_4);

uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
UDMA_ARB_4);

uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC0_BASE + ADC_O_SSFIFO0),
g_ui8RxBufA, sizeof(g_ui8RxBufA));
uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC0_BASE + ADC_O_SSFIFO0),
g_ui8RxBufB, sizeof(g_ui8RxBufB));

uDMAChannelEnable(UDMA_CHANNEL_ADC0);
ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS0);
IntEnable(INT_ADC0SS0);


}

void
ConfigureUART(void)
{

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);


GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);


UARTStdioConfig(0, 115200, g_ui32SysClock);
}


int
main(void)
{

static uint32_t ui32PrevUARTCount = 0;
uint32_t ui32XfersCompleted;
uint32_t ui32BytesTransferred;

g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);


SysCtlPeripheralClockGating(true);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);


GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);


ConfigureUART();

UARTprintf("Tiva C Series @ %u MHz\n\n", g_ui32SysClock / 1000000);

UARTprintf("CPU\tRemaining\tMemory\t\t\t UART\n");
UARTprintf("Usage\tTime\t\tTransfers\t\t Transfers\n");


SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA);


IntEnable(INT_UDMAERR);

uDMAEnable();


uDMAControlBaseSet(pui8ControlTable);


InitUART1Transfer();


SysCtlSleep();


UARTprintf("\nStopped\n");

IntDisable(INT_ADC0SS0);
IntDisable(INT_UDMA);


}

  • May we note that your post's Subject/Title  "adc sequencer 3 using udma"    is not followed through to your code:  

    Prudhvi P said:
    ADCSequenceConfigure(ADC0_BASE, 0 /*SS0*/, ADC_TRIGGER_ALWAYS, 3 /*priority*/);

    If such, "Attention to Detail" is missed (so gravely)  - does this not suggest that, "Further time/effort - by you - in code review IS required?"

    In addition - "KISS" strongly argues for your,  "Breaking such a complex whole into its constituent parts" -  and then "Attacking each one - in a systematic fashion."      That's NOT done here - thus error may invade from multiple (as of yet untested sources) - making issue resolution FAR HARDER & LONGER...      Can that (ever) be good?

  • Here is a sample project that I originally did for TM4C123, but I modified for TM4C1294. It uses a general purpose timer to start an A to D conversion on AIN1 (PE2) and then uses the uDMA in ping-pong mode to capture the data. It prints the average of each buffer out UART0.

    /cfs-file/__key/communityserver-discussions-components-files/908/7450.ADCwDMA.zip

  • Might "spoon-feeding" degrade "real-learning" - should that not receive (some) consideration?

    Blending MULTIPLE ELEMENTS and/or MCU Peripherals - all together - w/out the provision of, "Necessary Cautions" (may) temporarily "Solve today's issue" - but proves (highly) questionable for all those "coming!"