AnsweredAssumed Answered

SPI Interface to AD5390

Question asked by sashagn on Jun 27, 2018
Latest reply on Jul 2, 2018 by rrosario

Hello,

 

I am trying to interface between ADuCM310 and AD5390 through SPI0, but dont get any response from the DACs. To start, I am using the SPI Master example from ADuCM310. The SPI setup and transmit functions looks as following:

 

void SPI0MasterSetup(void)
{
DioCfg(pADI_GP0,0x0055); //  SPI0 pins
SpiBaud(pADI_SPI0,80,SPIDIV_BCRST_EN| // Select 1Mhz SPI CLock, Enable chip select edge detect IRQ source,
SPIDIV_CSIRQ_EN|SPIDIV_HFM_EN); // Enable resetting of internal bit-shift counter
SpiCfg(pADI_SPI0,SPICON_MOD_TX1RX1, // Enable interrupt after 1 byte transfer
SPICON_MASEN_EN,SPICON_CON_EN|SPICON_RXOF_EN| // Enable master, SPI mode, Rx overflow interrupt
SPICON_ZEN_EN|SPICON_TIM_TXWR| // transfer 0 if FIFO is empty, initiate trasnfer on write to SPITX register
SPICON_CPOL_HIGH|SPICON_CPHA_SAMPLETRAILING| // SPI clock idles high, samples on falling clock edge
SPICON_ENABLE_EN); // Enable SPI0
NVIC_EnableIRQ(SPI0_IRQn); // Enable SPI0 interrupt source
}


unsigned char SPI0WritePacket(unsigned int length )
{
// Transmit
ucTransmitInProgress = 1; // Number of bytes to transfer
SpiCfg(pADI_SPI0,SPICON_MOD_TX1RX1, // Enable interrupt after 1 byte transfer
SPICON_MASEN_EN,SPICON_CON_EN|SPICON_RXOF_EN| // Enable master, SPI mode, Rx overflow interrupt
SPICON_ZEN_EN|SPICON_TIM_TXWR| // transfer 0 if FIFO is empty, initiate trasnfer on write to SPITX register
SPICON_CPOL_HIGH|SPICON_CPHA_SAMPLETRAILING| // SPI clock idles high, samples on falling clock edge
SPICON_ENABLE_EN); // Enable SPI0

SpiFifoFlush(pADI_SPI0,SPICON_TFLUSH_EN,
SPICON_RFLUSH_EN); // Flush Master Tx FIFO
SpiFifoFlush(pADI_SPI0,SPICON_TFLUSH_DIS,
SPICON_RFLUSH_DIS);
ucSPIWrCnt = 0;
SpiTx(pADI_SPI0,ucTransfer[ucSPIWrCnt++]); // send SPI0 byte

while (ucTransmitInProgress == 1)
{}

return 1;
}

 

In the main function I am trying to toggle in a continuous loop between the max and min values but with no success:

...

ucLength = 3;
ucTransfer[0] = 0xFF;
ucTransfer[1] = 0xFF;
ucTransfer[2] = 0x42;
SPI0WritePacket(ucLength);

 

delay(100);


ucTransfer[0] = 0x00;
ucTransfer[1] = 0xC0;
ucTransfer[2] = 0x42;
SPI0WritePacket(ucLength);

 

 

Can you please suggest where my error could be? 

Outcomes