AnsweredAssumed Answered

BF548 SPI DMA receive

Question asked by KPAN on Feb 28, 2013
Latest reply on Mar 20, 2013 by SachinV

Hi All,

 

I am using BF548 SPI using DMA in master mode.

I have interfaced AD7357 with BF548. Everything is working properly.

I am continuously getting the sample data in buffer.

I want to analyse every sample when it is received apply some algorithm and save the data in DDRRAM and SD card.

As it is DMA transfer I am thinking where should I write the code for analyzing the samples.

As I want to use SPI at maximum speed, it is very difficult to sync with he speed.

Where should i write the codefor analysing each sample?

 

 

/******************************************************************************/

#define BUFFER_COUNT (4)

#define DATA_COUNT (2048)

static u16 Data[DATA_COUNT * BUFFER_COUNT];

static ADI_DEV_1D_BUFFER Buffer[BUFFER_COUNT];

static ADI_DEV_DEVICE_HANDLE SPIHandle;

 

  ADI_DEV_CMD_VALUE_PAIR SPIConfig[] = {

{ ADI_DEV_CMD_SET_DATAFLOW_METHOD, (void *)ADI_DEV_MODE_CHAINED_LOOPBACK }, // chained loopback

{ ADI_SPI_CMD_SET_BAUD_REG, (void *)0x12 }, // run at some rate

{ ADI_SPI_CMD_SET_WORD_SIZE, (void *)16 }, // word size 16 bits

{ ADI_SPI_CMD_ENABLE_SLAVE_SELECT, (void *)3 }, // device is on SS 4

{ ADI_SPI_CMD_SELECT_SLAVE, (void *)3 }, // enable the device

{ ADI_SPI_CMD_SET_CONTROL_REG, (void *)0x1122},

{ ADI_DEV_CMD_END, NULL }

};

 

Result = adi_dev_Open(adi_dev_ManagerHandle, &ADISPIDMAEntryPoint, 0, 0, &SPIHandle,

ADI_DEV_DIRECTION_INBOUND, adi_dma_ManagerHandle, NULL, &Callback);

 

Result = adi_dev_Control(SPIHandle, ADI_DEV_CMD_TABLE, SPIConfig);

 

for (i = 0; i < BUFFER_COUNT; i++) {

Buffer[i].Data = &Data[i * DATA_COUNT];

Buffer[i].ElementCount = DATA_COUNT;

Buffer[i].ElementWidth = 2;

Buffer[i].CallbackParameter = NULL;//&Buffer[i];

Buffer[i].pNext = &Buffer[i+1];

}

Buffer[i-1].pNext = NULL;

 

  Result = adi_dev_Read(SPIHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *)Buffer);

 
Result = adi_dev_Control(SPIHandle, ADI_DEV_CMD_SET_DATAFLOW, (void *)TRUE);

 

while(1)

{

}

/****************************************************************************************************/

 

Data[8192] is the array in which I am receiving samples.

If I access all the elements from while(1) in a loop to write it into SD card, speed is not syncronising and shape of the waveform is distorted in excel sheet because of repeating/missing samples.

 

Can you help me with the same?

 

Thanks in advance.

 

Regards,

KP

Outcomes