This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multiple SPI device in MotorWare 16bit and 24bit.

Other Parts Discussed in Thread: MOTORWARE, DRV8305

Do you have examples of Multiple SPI device in MotorWare? i have two SPI device 16 bit (DRV8305) und 24 bit with different SPI Mode.

  • Andrew,

    Are you asking for an example showing how to use (1) SPI for the DRV8305 and another SPI for a different external device?

    Do you require 24-bit character length for this other device? If so, the McBSP (multi-channel buffered serial port) is a good option offering 32-bit character length. SPI only offers 16-bit character length so you would need to manage 2 SPI characters to produce the single 24-bit data. Possible, but tricky.
  • Thanks. I will think.
    Is it possible to reconfigure SPI for other device 8 Bit mode and GPIO as CS, and return SPI settings for DRV8305. Work WotorMare normal?
  • I use GPIO as CS. Is there a good decision for the correct timing management of CS SPI? To use a delay cycle for SPI CS is not very good.

  • Andrew,

    The time it takes for the SW to set the GPIO low and then write the data to the SPI TX FIFO should be enough time for the SPI slave enable.

    How much time does your SPI slave device require?

    Jeff
  • Hi, everybody,

    help to find a mistake. I have  me two configurations for SPIa. Each of them works well.

    When I switch from a SPIa >  MCP2515  > SPIa.

    I read the wrong data.

    void HAL_setupSpiA(HAL_Handle handle)
    {
      HAL_Obj   *obj = (HAL_Obj *)handle;
    
      SPI_reset(obj->spiAHandle);
      SPI_setMode(obj->spiAHandle,SPI_Mode_Master);
      SPI_setClkPhase(obj->spiAHandle, SPI_ClkPhase_Normal);
      SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
      SPI_enableTx(obj->spiAHandle);
      SPI_enableTxFifoEnh(obj->spiAHandle);
      SPI_enableTxFifo(obj->spiAHandle);
      SPI_enableRxFifoInt(obj->spiAHandle);
      SPI_setTxDelay(obj->spiAHandle,0x0010);
      SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x0001));
      SPI_setCharLength(obj->spiAHandle,SPI_CharLength_16_Bits);
      SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free);
      SPI_enable(obj->spiAHandle);
    
      return;
    }  // end of HAL_setupSpiA() function
    #endif
    
    #ifdef MCP2515
    void HAL_setupSpi_MCP2515(HAL_Handle handle)
    {
      HAL_Obj   *obj = (HAL_Obj *)handle;
    
      SPI_reset(obj->spiAHandle);
      SPI_setMode(obj->spiAHandle,SPI_Mode_Master);
      SPI_setClkPhase(obj->spiAHandle, SPI_ClkPhase_Delayed);
      SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
      SPI_enableTx(obj->spiAHandle);
      SPI_disableTxFifoEnh(obj->spiAHandle);
      SPI_disableRxFifoInt(obj ->spiAHandle);
      SPI_enableInt(obj->spiAHandle);
      //SPI_setTxDelay(obj->spiAHandle,0x0010);
      SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x0001));
      SPI_setCharLength(obj->spiAHandle,SPI_CharLength_8_Bits);
      SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free);
      SPI_enable(obj->spiAHandle);
    
      return;
    }  // end of HAL_setupSpi_MCP2515() function
    #endif

    #ifdef DRV8305_SPI
      // turn on the DRV8305 if present
      HAL_enableDrv(halHandle);
      // initialize the DRV8305 interface
      HAL_setupDrvSpi(halHandle,&gDrvSpi8305Vars);
    #endif
    
    #ifdef MCP2515
    
      HAL_setupSpi_MCP2515(halHandle);
      SPI_ReadByte = MCP2515_begin(halHandle->mcp2515Handle, CAN_500KBPS);
    
      MCP2515_init_Mask(halHandle->mcp2515Handle, 0, 0, 0x000F);
      MCP2515_init_Filt(halHandle->mcp2515Handle, 0, 0, NODE_ID /*getNodeId(&ObjDict_Data)*/); // RxPDO and SDO
      MCP2515_init_Filt(halHandle->mcp2515Handle, 1, 0, NODE_ID /*getNodeId(&ObjDict_Data)*/); // same
    
      MCP2515_init_Mask(halHandle->mcp2515Handle, 1, 0, 0x07FF);
    //  MCP2515_init_Filt(halHandle->mcp2515Handle, 2, 0, 0x0000); // NMT
    //  MCP2515_init_Filt(halHandle->mcp2515Handle, 3, 0, 0x0080); // sync
    //  MCP2515_init_Filt(halHandle->mcp2515Handle, 4, 0, 0x0100); // time stamp
    //  MCP2515_init_Filt(halHandle->mcp2515Handle, 5, 0, 0x0000); // dummy
    
      HAL_setupSpiA(halHandle); //Added
    #endif

  • Why doesn't change the phase after switching of settings?
    without HAL_setupSpi_MCP2515(halHandle);

    after 

    HAL_setupSpi_MCP2515(halHandle);

    HAL_setupSpiA(halHandle);

  • Error in SPI.C library.

    void SPI_setClkPhase(SPI_Handle spiHandle,const SPI_ClkPhase_e clkPhase)
    {
      SPI_Obj *spi = (SPI_Obj *)spiHandle;
    
      // clear the bits
      spi->SPICTL &= (~SPI_SPICTL_CLK_PHASE_BITS);  // Add Andrew
    
      // set the value
      spi->SPICTL |= clkPhase;
    
      return;
    } // end of SPI_setClkPhase() function

  • Andrew,

    Thank you for finding this and clearly noting it. I have filed the bug report and your correction to the SW is confirmed, it will be fixed in a future MW release.

    Have a good day,
    Jeff