Post Go back to editing

Using SPI2 and OSPI at the same time

Category: Software
Product Number: ADSP-SC594
Software Version: CCES 2.10.1

I am using OSPI to read the flash chip using adi_ospi_DirectRead. At the same time, i am using SPI2 to send a bitstream to an FPGA. When the SPI transactions for both peripherals happen at the same time. The DMA for the OSPI seems to lock up. It never seems to finish it's transaction. When using core mode instead of DMA, the processor locks up. No exception handler or anything. It just stops working.

If i use SPI1 instead of SPI2 there is no issue.

Any idea what might be the issue here? I have tried remapping the memeory of the OSPI by setting *pREG_SCB5_SPI2_OSPI_REMAP = 0x1, but this does not fix the issue.

Parents
  • Hi,

    By any chance have you configured PORTA for OSPI. If so, please note that this will not work, as SPI2 and OSPI are multiplexed on PORTA.

    To use both interfaces simultaneously, we recommend assigning SPI2 to PORTA and OSPI to PORTC.

    If this does not resolve your issue, could you please share the sequence of OSPI and SPI API calls you're using? Alternatively, it would be very helpful if you could provide a simple project that reproduces the issue for us to simulate.

    Regards,
    Nandini C

  • For OSPI i am using port C, for SPI2 i am using port A.

    To initialize OSPI i use following calls:

    adi_ospi_Open(pDevice->oSpi.pSpiDevMem,
                    sizeof(pDevice->oSpi.pSpiDevMem),
                    OSPI_ADI_MDMAUSED, ADI_DMA_MEMDMA_S1, &(pDevice->oSpi.hDev));
                    
    adi_ospi_ConfigBaud(pDevice->oSpi.hDev, ADI_OSPI_BAUD_DIV_BY_16);
    
    adi_ospi_UpdateReadDelay(pDevice->oSpi.hDev, 8);
    
    adi_ospi_RegisterCallback (pDevice->oSpi.hDev, NULL, Callback, pDevice);

    Then I do multiple calls to

    adi_ospi_DirectRead(pDevice->oSpi.hDev,&oDacCmd);

    to read from the device. Each time waiting for the callback before initiaing a new read.

    For the SPI i initialize with:

    adi_spi_Open (oHalSpiBus[eBus].nSpiBus,
    	                        ADI_SPI_DIR_BIDIRECTION,
    							oHalSpiBus[eBus].pSpiMemory,
    							ADI_SPI_BIDIR_MEMORY_SIZE,
    							&(oHalSpiBus[eBus].hSpi));
    							
    adi_spi_SetasMaster(oHalSpiBus[eBus].hSpi, true);
    adi_spi_SetHWSlaveSelect(oHalSpiBus[eBus].hSpi, false);
    adi_spi_SetClockPhase(oHalSpiBus[eBus].hSpi,  true);
    adi_spi_SetClock(oHalSpiBus[eBus].hSpi, (div-1));
    adi_spi_SetClockPolarity(oHalSpiBus[eBus].hSpi, true);
    adi_spi_RegisterCallback(oHalSpiBus[eBus].hSpi, SpiCallback, &oHalSpiBus[eBus]);
    
    
    adi_spi_SetWordSize(oHalSpiBus[eBus].hSpi, ADI_SPI_WORDSIZE_8BIT);
    	

    Then i do multiple calls to

    adi_spi_DMAWrite(hSpi, oTransceiver.pTransmitter, 1, ADI_PDMA_STOP_MODE);

    to write to the device, Each time waiting for the callback before starting a new write.

    Like i said, it works as long as the transaction for each peripheral does not happen at the same time. If they happen at the same time The DMA of the OSPI hangs.

  • Hi,

    We are unable to simulate the issue when OSPI and SPI2 is used. Could you please clarify the below questions to understand the issue better:

    Could you please share a screenshot of CCES and the call stack at the moment the OSPI hangs?
    Regarding your statement, “When the SPI transactions for both peripherals happen at the same time” — could you clarify how the transactions are occurring simultaneously, and how you determined this?
    Are you receiving any error events in the OSPI callback?
    We’ve used the pseudocode below for OSPI and SPI2 transactions, and we haven’t encountered any hangs for long runs. Could you please review it and let us know if we missed anything?
         
          eResult = adi_ospi_DirectRead(*phDevice, &DAC_Read_Command);
          spi_eResult = adi_spi_DMAWrite(hSPIMaster, Src_List, DMA_NUM_DESC, ADI_PDMA_STOP_MODE);     
          while (1)
         {
                      if (OSPI_Callbackcount == 1)
                      {
                                  OSPI_Callbackcount = 0;
                                  /* Perform the read operation from flash in QPI DTR mode */
                                  eResult = adi_ospi_DirectRead(*phDevice, &DAC_Read_Command);                         
                      }

                      if (spi_CallbackCount == 1)
                      {
                                  spi_CallbackCount = 0;
                                  spi_eResult = adi_spi_DMAWrite(hSPIMaster, Src_List, DMA_NUM_DESC, ADI_PDMA_STOP_MODE);
                       }
          }

    Regards,
    Nandini C

Reply
  • Hi,

    We are unable to simulate the issue when OSPI and SPI2 is used. Could you please clarify the below questions to understand the issue better:

    Could you please share a screenshot of CCES and the call stack at the moment the OSPI hangs?
    Regarding your statement, “When the SPI transactions for both peripherals happen at the same time” — could you clarify how the transactions are occurring simultaneously, and how you determined this?
    Are you receiving any error events in the OSPI callback?
    We’ve used the pseudocode below for OSPI and SPI2 transactions, and we haven’t encountered any hangs for long runs. Could you please review it and let us know if we missed anything?
         
          eResult = adi_ospi_DirectRead(*phDevice, &DAC_Read_Command);
          spi_eResult = adi_spi_DMAWrite(hSPIMaster, Src_List, DMA_NUM_DESC, ADI_PDMA_STOP_MODE);     
          while (1)
         {
                      if (OSPI_Callbackcount == 1)
                      {
                                  OSPI_Callbackcount = 0;
                                  /* Perform the read operation from flash in QPI DTR mode */
                                  eResult = adi_ospi_DirectRead(*phDevice, &DAC_Read_Command);                         
                      }

                      if (spi_CallbackCount == 1)
                      {
                                  spi_CallbackCount = 0;
                                  spi_eResult = adi_spi_DMAWrite(hSPIMaster, Src_List, DMA_NUM_DESC, ADI_PDMA_STOP_MODE);
                       }
          }

    Regards,
    Nandini C

Children
No Data