Post Go back to editing

Two BF703 SPI connection

Category: Software
Product Number: ADSP-BF703

We want to connect two BF703 use SPI interface , the connection as below

DSP1(Controller)--    DSP2(Target)

SPI2_Clk     ---- SPI2_Clk
SPI2_MISO ---- SPI2_MISO

SPI2_MOSI ---- SPI2_MOSI 
SPI2_SEL2 ---- SPI2_SEL2

I got below sample project

[FAQ] : Sample project for BF707 SPI quad mode - Documents - CrossCore Embedded Studio and Add-ins - EngineerZone (analog.com)

After Modified quad707_transmit code

adi_spi_SetClock(phSPI, 1000u);

adi_spi_SetSlaveSelect(phSPI, ADI_SPI_SSEL_ENABLE2 );

adi_spi_SetTransceiverMode(phSPI, ADI_SPI_TXRX_MODE);

Using LogicAnalyzer DSP1 SPI2 MOSI can transfer 1000 number of 32-bit data

But probelm on quad707_receive side.

DSP2 can't reveive data, modified code as below

int main(int argc, char *argv[])
{
/**
* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success
*/
adi_initComponents();
adi_pwr_Init(0u,25000000);
adi_pwr_SetFreq(0u,400000000,200000000);

ConfigSoftSwitches();
SpuConfig();
SlaveConfig();

#ifdef SPI_MASTER_TX
inputData();
#endif
printf("Data Recive Start");

if (result == 0u)
{
/* submit the SPI transceiver's buffers */
result = adi_spi_SubmitBuffer(phSPI, &Xcv);
}
while(!b_slaveComplete);

printf("Data Recive finished");
#ifndef SPI_MASTER_RX
for(int i=0;i<BUFFER_SIZE;i++)
printf("Rxbuffer[%d]:%d\n",i,RxBuffer[i]);
#endif
}

void SpuConfig(void)
{
adi_spu_Init(0u, SpuMemory, NULL, NULL, &hSpu);
#ifdef DMA_MODE
adi_spu_EnableMasterSecure(hSpu, 22, true);
adi_spu_EnableMasterSecure(hSpu, 43, true);
adi_spu_EnableMasterSecure(hSpu, 44, true);

#endif
}

void SlaveConfig(void)
{
#ifdef DMA_MODE
if(result==0)
result=adi_spi_Open(2, &SpiMemory, ADI_SPI_DMA_MEMORY_SIZE, &phSPI);
#endif
#ifndef DMA_MODE
if(result==0)
result=adi_spi_Open(2, &SpiMemory, ADI_SPI_INT_MEMORY_SIZE, &phSPI);
#endif

if (result == 0u)
{
result = (uint32_t)adi_spi_SetMaster(phSPI, false);
}
if (result == 0u) 
{
result = (uint32_t)adi_spi_SetHwSlaveSelect(phSPI, true);
}
if (result == 0u) 
{
result = (uint32_t)adi_spi_SetClock(phSPI, 1000u);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetTransmitUnderflow(phSPI, true);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetClockPhase(phSPI, true);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetClockPolarity(phSPI,false);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetWordSize(phSPI, ADI_SPI_TRANSFER_32BIT);
}
#ifdef DMA_MODE
/* enable DMA */
if (result== 0u)
{
result = (uint32_t)adi_spi_EnableDmaMode(phSPI, true);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetDmaTransferSize(phSPI,ADI_SPI_DMA_TRANSFER_32BIT);
}
#endif
/* if (result == 0u)
{
result = adi_spi_SetSlaveSelect(phSPI, ADI_SPI_SSEL_ENABLE2 );

}
*/
if (result == 0u)
{
result = (uint32_t)adi_spi_SetTxWatermark(phSPI,
ADI_SPI_WATERMARK_50,
ADI_SPI_WATERMARK_DISABLE,
ADI_SPI_WATERMARK_DISABLE);
}
if (result == 0u)
{
result = (uint32_t)adi_spi_SetRxWatermark(phSPI,
ADI_SPI_WATERMARK_50,
ADI_SPI_WATERMARK_DISABLE,
ADI_SPI_WATERMARK_DISABLE);
}

if (result == 0u)
{
result = adi_spi_SetTransceiverMode(phSPI, ADI_SPI_TXRX_MODE);

}
/* if (result == 0u)
{
result = adi_spi_StartOnMosi(phSPI, true);
}
*/
if (result == 0u)
{
result = adi_spi_RegisterCallback(phSPI, SpiCallback_Slave, NULL);
}
}

Thread Notes

  • Hi,

    We have reviewed the code snippet seems it is fine.

    And you confirmed that DSP1's SPI2 MOSI can transfer 1000 number of 32-bit data. So, we suspect that you have missed your pin multiplexing configuration for SSEL2 in your code.

    Please confirm whether you have changed the Pin Multiplexing configuration to "SEL2 (Port: B, Mux: 2,Bit: 16, GPIO pin:8)" for both transmit and receive codes.

    Please ensure that you have followed the below steps while running the application.
    1. Import the transmit and receive projects in different workspaces.
    2. Change processor as BF703 and Silicon Revision as any, by navigating right click on the project > properties > C/C++ Build > Settings > Processor Settings and "Apply and Close".
    3. Build both projects and configure the sessions individually.
    4. First run the receive code, now the "DSP2(Target)" waiting for SPI transaction.
    5. Second run the transmit code to perform the SPI transaction.

    Also please ensure that proper grounding has been done between breakout boards if you are using in your custom board.

    Please try the above things and let us know how you are getting on.

    If you are still facing the issue, please share your complete project for a review. 

    Regards,
    Santhakumari.K

  • Bf707_SPI_slave_test.zip

    I have checked above items, but still not working.

    Attached full project code for Target side, 

  • Hi,

    In the earlier mail, the shared snippet contains SPI code using driver APIs. But in the attached project, it is a register based code. Can you please confirm whether the correct project has been shared to us.

    Awaiting for your reply.

    Best Regards,
    Santhakumari.K

  • I re-write SPI_Slave code using register based, this is correct project, however I found one of our PCBA can recive SPI2 data by attached code, so this may our HW issue. we are still looking on it. 

  • Hi Jay,

    Thank you for the update!!!

    Best Regards,

    Santhakumari.K