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.

TMS320C6746: edma for scaning data from adc

Part Number: TMS320C6746
Other Parts Discussed in Thread: ADS8588H

dear ti,

i am getting data from ads8588h with tms320c6746 over spi, i do get some data  but what i see is edma is not working as i needed,

i needed dsp to scan some fixed number of samples e.g. 256 samples of 50hz wavefrom from ads8588h, and number of samples of 50hz wavefrom should not vary,

i have verified and read that adc is capable of giving much higher number of samples, i used spi only without dma and accurately got more than 1500 samples of 50hz waveform applied to adc8588h,

 but with edma in tms320c6746, i get only 4-5 samples of 50hz waveform,i am sure that adc is converting and generating as many samples as it can convert, but controller is unable to fetch that out of adc ,

i see that code goes to Edma3CCErrHandlerIsr(void), it looks like dsp is stuck in edma handler for long time and again and again, so it take more time to fetch data from adc, any insights into this would be helpful as it has been 2-3 days i am fiddling with code to find out issue 

here is my code, i will share some more code if needed once we start conversation

int main(void)
{
/* Waking up the SPI0 instance. */
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_SPI0, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);

PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);


/* FOR DMA */
/* Enabling the PSC for EDMA3CC_0).*/
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_CC0, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);

/* Enabling the PSC for EDMA3TC_0.*/
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_TC0, PSC_POWERDOMAIN_ALWAYS_ON,
PSC_MDCTL_NEXT_ENABLE);

GPIOADCPinsSetup();
#ifdef DMA
StartADCConversion(0);
#endif
/************************************/
SPIPinMuxSetup(0);

/* Configuring and enabling the SPI1 instance. */
SetUpSPI();
#ifdef DMA
/*spi with dma 18nov21*/
/* Initializes the EDMA3 Instance. */
EDMA3Initialize();
//#ifndef DMA_LOOP
ConfigureADCBusyInterrupt();
//#endif

/* Request EDMA3CC for Tx and Rx channels for SPI1. */
RequestEDMA3Channels();

/* Request DMA Channel and TCC for SPI Receive*/
#endif
/* Enable SPI communication */
SPIEnable(SOC_SPI_0_REGS);

// SetDMATransfer();

ResetADC();
CSADC(0);

#ifdef DMA
while(1)
{
StartADCConversion(1); // it set a gpio which is connected to adc, adc starts conversion when low to high detected( it takes maximum 18us to convert data, i my case it is converts in 3.8us)
Busy = 1;
while(Busy); // adc gives interrupt and i capture it on gpio and clear busy flag 

DataTransferUsingDMA();


}

/////////////////////////////////////////////////////////////////////////////////////////////////

// i send 16 dummy bytes over spi to adc to get 16 data bytes in return( adc has 8 channels and send every channels has a 2 bytes data,so 8x2 data bytes)

////////////////////////////////////////////////////////////////////////////////////////////////

/*
** This function enables the SPI Flash for writing.
*/

static void DataTransferUsingDMA(void)
{
unsigned int buffLength = 0;
int j;
for(j = 0; j < 16; j++)
{
TxDummyData[j] = 0xAA;
}

buffLength = j;

/* Configure the PaRAM registers in EDMA for Transmission. */
SpiTxEdmaParamSet(EDMA3_CHA_SPI0_TX, EDMA3_CHA_SPI0_TX, TxDummyData, buffLength);

/* Registering Callback Function for Transmission. */
cb_Fxn[EDMA3_CHA_SPI0_TX] = &callback;

/* Configure the PaRAM registers in EDMA for Reception. */
SpiRxEdmaParamSet(EDMA3_CHA_SPI0_RX, EDMA3_CHA_SPI0_RX, RxData, buffLength, TRUE);

/* Registering Callback Function for Reception. */
cb_Fxn[EDMA3_CHA_SPI0_RX] = &callback;

/* Assert the CSHOLD line corresponding to the SPI Flash. */
//CSHoldAssert();

// CSADC(0);

/* Enable SPI controller to generate DMA events */
SPIIntEnable(SOC_SPI_0_REGS, SPI_DMA_REQUEST_ENA_INT);

/* Wait until both the flags are set to 1 in the callback function. */
while ((0 == flagTx) || (0 == flagRx));

flagTx = 0;
flagRx = 0;

/* Deassert the CSHOLD line corresponding to the SPI Flash. */
//CSHoldDeassert();

// CSADC(1);
StartADCConversion(0);
/* Wait until SPI Flash is enabled for writing. */
// while (IsWriteEnabled() != TRUE);
}