Hello,
I am trying to create a sine wave generator using a DAC and I communicate wth it over SPI. The problem is that the "adi_SPI_MasterTransfer" function in the ADuCM350 SDK does not allow me to transfer data fast enough.
With the 8MHz clock frequency and only sending 3 bytes per point from a lookup table (256 points max) to the DAC I gant only reach a sine wave of 42Hz.
How could I decrease the time needed to send data ?
Here is my SPI function I use:
void SPI_DAC(uint16_t DACreg)
{
gTransmitBuffer[0] = 0x00;
gTransmitBuffer[1] = ((uint8_t)((DACreg>>8) & 0xFF));
gTransmitBuffer[2] = (DACreg & 0xFF);
gPrologueBuffer[0] = 0x00;
transceive.pPrologue = gPrologueBuffer;
transceive.PrologueSize = 0;
transceive.pTxData = gTransmitBuffer;
transceive.pRxData = gGarbageBuffer;//gReceiveBuffer;
transceive.DataSize = 3;
transceive.bTxIncrement = true;
transceive.bRxIncrement = false;
adi_GPIO_SetLow(ADI_GPIO_PORT_0,ADI_GPIO_PIN_0);
adi_SPI_MasterTransfer(hDevice, &transceive);
adi_GPIO_SetHigh(ADI_GPIO_PORT_0,ADI_GPIO_PIN_0);
}
And here is my SPI initialization
ADI_SPI_RESULT_TYPE initSPI(void)
{
ADI_SPI_DEV_ID_TYPE const devID = ADI_SPI_DEVID_0;
ADI_SPI_RESULT_TYPE Result = ADI_SPI_SUCCESS; /* assume the best */
ADI_SPI_DEV_GENERIC_SETTINGS_TYPE settings;
*((volatile uint32_t *)REG_GPIO3_GPCON) |= SPI0_SCLK_PORTP3_MUX
| SPI0_MISO_PORTP3_MUX | SPI0_MOSI_PORTP3_MUX;// | SPI0_CS_PORTP3_MUX;
/* install and enable DMA error interrupt handeling with OSAL */
// ADI_INSTALL_HANDLER(DMA_ERR_IRQn, DMA_Err_Int_Handler); // BrJ
// ADI_ENABLE_INT(DMA_ERR_IRQn); // BrJ
/* Initialize SPI */
if ((Result = adi_SPI_MasterInit(devID, &hDevice)) != ADI_SPI_SUCCESS) return Result;
/* configure SPI */
if ((Result = ConfigureSPI(hDevice)) != ADI_SPI_SUCCESS) return Result;
if ((Result = adi_SPI_GetGenericSettings(hDevice, &settings)) != ADI_SPI_SUCCESS) return Result;
return ADI_SPI_SUCCESS;
}
ADI_SPI_RESULT_TYPE ConfigureSPI(ADI_SPI_DEV_HANDLE hSpi)
{
ADI_SPI_RESULT_TYPE Result = ADI_SPI_SUCCESS; /* assume the best */
while (1) {
/* disable DMA (initially) */
if ((Result = adi_SPI_SetDmaMode(hSpi, false)) != ADI_SPI_SUCCESS) return Result;
/* set blocking mode so DMA transfers complete without need to poll */
if ((Result = adi_SPI_SetBlockingMode(hSpi, false)) != ADI_SPI_SUCCESS) return Result;
// Set MSB first
if ((Result = adi_SPI_SetLsbFirst(hSpi, false)) != ADI_SPI_SUCCESS) return Result;
/* send zeros if tx SPI underflows*/
if ((Result = adi_SPI_SetTransmitUnderflow(hSpi, true)) != ADI_SPI_SUCCESS) return Result;
/* data transitions on rising edge of clock */
if ((Result = adi_SPI_SetClockPhase(hSpi, true)) != ADI_SPI_SUCCESS) return Result;
/* data transitions on rising edge of clock */
if ((Result = adi_SPI_SetClockPolarity(hSpi, false)) != ADI_SPI_SUCCESS) return Result;
/* run the SST25LF020A up to 1/2 core clock */
if ((Result = adi_SPI_SetBitrate(hSpi, SPI_CLOCK)) != ADI_SPI_SUCCESS) return Result;
uint32_t freq = adi_SPI_GetBitrate(hSpi);
/* success */
return ADI_SPI_SUCCESS;
} /* end while */
}
I have approximately 10us between each of my 3 bytes I send and 90us between data blocks.

Thank you !
Edit Notes
Add SPI clock measurement time[edited by: JimmySIP at 5:59 AM (GMT -4) on 30 Sep 2021]
