Part Number: SW-EK-TM4C1294XL
Other Parts Discussed in Thread: EK-TM4C1294XL
Tool/software: Code Composer Studio
HI Friends,
Iam working tm4c1294xl evaluation kit i was working adc sample squencer 3 using udma transfer. My problem was i was unable to print the value sampled using adc. Iam attaching code with with this post can any help with this issue.
#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[1];
static uint32_t g_ui8RxBufB[1];
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 < 1; ui16Idx++)
{
UARTprintf("printing forom receiver side");
UARTprintf("hello receiver %d \n ",g_ui8RxBufA[ui16Idx] );
}
ADCIntClearEx(ADC0_BASE, ADC_INT_DMA_SS0 | ADC_INT_SS0);
if (uDMAChannelModeGet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT) == UDMA_MODE_STOP) {
uDMAChannelTransferSet((UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT), UDMA_MODE_PINGPONG, (void *)(ADC0_BASE), 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 ), g_ui8RxBufB, sizeof(g_ui8RxBufB));
}
}
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, 3 /*SS0*/, ADC_TRIGGER_ALWAYS, 0 /*priority*/); // SS0-SS3 priorities must always be different
ADCSequenceStepConfigure(ADC0_BASE, 3 /*SS0*/, 0, ADC_CTL_CH0 | ADC_CTL_END | ADC_CTL_IE); // ADC_CTL_IE fires every 8 samples
ADCSequenceEnable(ADC0_BASE, 3);
ADCSequenceDMAEnable(ADC0_BASE, 3);
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),
g_ui8RxBufA, sizeof(g_ui8RxBufA));
uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC0_BASE ),
g_ui8RxBufB, sizeof(g_ui8RxBufB));
uDMAChannelEnable(UDMA_CHANNEL_ADC0);
ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS3);
IntEnable(INT_ADC0SS3);
}
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;
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);
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_ADC0SS3);
IntDisable(INT_UDMA);
}
Regards
Prudhvi