Hello Guys,
I have ADC0 working with DMA, sampling the temp sensor on a 129x. I want to get ADC1 working with DMA. I would like to get them working together, but first, I cannot even get ADC1 working with DMA Independently.
here is my project, working with ADC0 and DMA: ADC0-DMA-working.zip
here is the code, for ADC1 and DMA.I pretty much commented the ADC0, and replaced it with ADC1 equivalent. I know DMA is not working, because when I place a breakpoint on like 384, after uDMAChannelEnable(UDMA_CHANNEL_ADC1); and ADCIntEnableEx(ADC1_BASE, ADC_INT_DMA_SS0), and then check the buffer, nothing is in it.
here is the project: ADC1-DMA-notworking.zip
here is the code:
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_adc.h"
#include "inc/hw_types.h"
#include "inc/hw_udma.h"
#include "inc/hw_emac.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/adc.h"
#include "driverlib/udma.h"
#include "driverlib/emac.h"
uint32_t gui32ADC0Value[2];
uint32_t gui32ADC1Value[2];
volatile uint32_t gui32ADCIntDone[2];
#pragma DATA_ALIGN(pui8ControlTable, 1024)
uint8_t pui8ControlTable[1024];
#define MEM_BUFFER_SIZE 256
static uint32_t g_ui8RxBufA[MEM_BUFFER_SIZE*5];
static uint32_t g_ui8RxBufB[MEM_BUFFER_SIZE*5];
//*****************************************************************************
//
//! \addtogroup adc_examples_list
//! <h1>Single Ended ADC (single_ended)</h1>
//!
//
//*****************************************************************************
void
uDMAErrorHandler(void)
{
uint32_t ui32Status;
//
// Check for uDMA error bit
//
ui32Status = uDMAErrorStatusGet();
//
// If there is a uDMA error, then clear the error and increment
// the error counter.
//
if(ui32Status)
{
uDMAErrorStatusClear();
}
}
volatile int counter= 0;
void ADCseq0Handler(){
uint32_t ui32Status;
uint32_t ui32Mode;
// ADCIntClearEx(ADC0_BASE, ADC_INT_DMA_SS0);
ADCIntClearEx(ADC1_BASE, ADC_INT_DMA_SS0);
//ui32Mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT);
ui32Mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC1 | UDMA_PRI_SELECT);
if(ui32Mode == UDMA_MODE_STOP)
{
//
// uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
//
// UDMA_MODE_PINGPONG,
//
// (void *)(ADC0_BASE + ADC_O_SSFIFO0),
//
// g_ui8RxBufA, MEM_BUFFER_SIZE);
uDMAChannelTransferSet(UDMA_CHANNEL_ADC1 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC1_BASE + ADC_O_SSFIFO1),
g_ui8RxBufA, MEM_BUFFER_SIZE);
}
//ui32Mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT);
ui32Mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC1 | UDMA_ALT_SELECT);
if(ui32Mode == UDMA_MODE_STOP)
{
// test2(&counter, &enable);
// uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
//
// UDMA_MODE_PINGPONG,
//
// (void *)(ADC0_BASE + ADC_O_SSFIFO0),
//
// g_ui8RxBufA, MEM_BUFFER_SIZE);
uDMAChannelTransferSet(UDMA_CHANNEL_ADC1 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC1_BASE + ADC_O_SSFIFO1),
g_ui8RxBufA, MEM_BUFFER_SIZE);
// counter++;
}
//uDMAChannelEnable(UDMA_CHANNEL_ADC0);
uDMAChannelEnable(UDMA_CHANNEL_ADC1);
}
void
InitUART1Transfer(uint32_t sysclock)
{
uint32_t div;
//SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
//SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC1);
//ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);
ADCClockConfigSet(ADC1_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1);
// ADCSequenceConfigure(ADC0_BASE, 0 /*SS0*/, ADC_TRIGGER_ALWAYS, 3 /*priority*/); // SS0-SS3 priorities must always be different
ADCSequenceConfigure(ADC1_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(ADC1_BASE, 0 /*SS0*/, 0, ADC_CTL_TS); // ADC_CTL_TS = read temp sensor
//ADCSequenceStepConfigure(ADC0_ASE, 0 /*SS0*/, 1, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 1, ADC_CTL_TS);
//ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 2, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 2, ADC_CTL_TS);
//ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 3, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 3, ADC_CTL_TS);
//ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 4, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 4, ADC_CTL_TS);
//ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 5, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 5, ADC_CTL_TS);
//ADCSequenceStepConfigure(ADC0_BASE, 0 /*SS0*/, 6, ADC_CTL_TS);
ADCSequenceStepConfigure(ADC1_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
ADCSequenceStepConfigure(ADC1_BASE, 0 /*SS0*/, 7, ADC_CTL_TS | ADC_CTL_END | ADC_CTL_IE); // ADC_CTL_IE fires every 8 samples
//ADCSequenceEnable(ADC0_BASE, 0);
ADCSequenceEnable(ADC1_BASE, 0);
//ADCSequenceDMAEnable(ADC0_BASE, 0);
ADCSequenceDMAEnable(ADC1_BASE, 0);
// uDMAChannelAttributeDisable(UDMA_CHANNEL_ADC0,
//
// UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
//
// UDMA_ATTR_HIGH_PRIORITY |
//
// UDMA_ATTR_REQMASK);
//
//
uDMAChannelAttributeDisable(UDMA_CHANNEL_ADC1,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
// uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
//
// UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
//
// UDMA_ARB_8);
uDMAChannelControlSet(UDMA_CHANNEL_ADC1 | UDMA_PRI_SELECT,
UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
UDMA_ARB_8);
// uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
//
// UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
//
// UDMA_ARB_8);
uDMAChannelControlSet(UDMA_CHANNEL_ADC1 | UDMA_ALT_SELECT,
UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
UDMA_ARB_8);
// uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT,
//
// UDMA_MODE_PINGPONG,
//
// (void *)(ADC0_BASE + ADC_O_SSFIFO0),
//
// g_ui8RxBufA, MEM_BUFFER_SIZE);
uDMAChannelTransferSet(UDMA_CHANNEL_ADC1 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC1_BASE + ADC_O_SSFIFO1),
g_ui8RxBufA, MEM_BUFFER_SIZE);
// uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT,
//
// UDMA_MODE_PINGPONG,
//
// (void *)(ADC0_BASE + ADC_O_SSFIFO0),
//
// g_ui8RxBufA, MEM_BUFFER_SIZE);
uDMAChannelTransferSet(UDMA_CHANNEL_ADC1 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(ADC1_BASE + ADC_O_SSFIFO1),
g_ui8RxBufA, MEM_BUFFER_SIZE);
// uDMAChannelAttributeEnable(UDMA_CHANNEL_ADC0,
// UDMA_ATTR_ALTSELECT |
// UDMA_ATTR_HIGH_PRIORITY);
uDMAChannelAttributeEnable(UDMA_CHANNEL_ADC1,
UDMA_ATTR_ALTSELECT |
UDMA_ATTR_HIGH_PRIORITY);
// uDMAChannelEnable(UDMA_CHANNEL_ADC0);
uDMAChannelEnable(UDMA_CHANNEL_ADC1);
// ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS0);
ADCIntEnableEx(ADC1_BASE, ADC_INT_DMA_SS0);
// IntEnable(INT_ADC0SS0);
IntEnable(INT_ADC1SS0);
}
int
main(void)
{
uint32_t sysclock;
sysclock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA);
IntMasterEnable();
IntEnable(INT_UDMAERR);
uDMAEnable();
uDMAControlBaseSet(pui8ControlTable);
InitUART1Transfer(sysclock);
while(1)
{
}
}
Thanks
Daniel