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.

TMS320F28375D: McBSP configuration for SPI Master or Slave Mode

Part Number: TMS320F28375D

Hello !!

I seek a correspondence between the modes of "spi" to know: SPI_PROT_POL0PHA0,SPI_PROT_POL0PHA1,SPI_PROT_POL1PHA0,SPI_PROT_POL1PHA1.

But at 10 mhz,a functional communication between a beaglebone and my dsp is is :

Spi mode CLKSTP CLKXP CLKRP
SPI_PROT_POL0PHA0 0 3 0 1
SPI_PROT_POL0PHA1 1 2 0 0
SPI_PROT_POL1PHA0 2 3 1 1
SPI_PROT_POL1PHA1 3 2 1 0
SPI_PROT_POL1PHA1 3 3 1 1

Can you guide me a little please?
Another question, it's possible that "MDRB" become MISO (data output) ,
and "MDxB" become MOSI (data input) in Slave mode?

Regards !
Cédric

  • Hey Cédric,

    Thanks for posting your question on the E2E Forum! Were going to get your issue solved and hopefully in the future this post will be able to help someone else out experiencing similar issues.

    I want to start by pointing you to section 21.7 in the following document:

    This section describes using the McBSP module in SPI Mode. Section 21.7.7 specifically talks about setting the module up as a SPI Slave. The following figure shows the McBSP pinout when running as SPI Slave.

      

    So your hunch for MDR and MDX is correct! 

    Go ahead and take a look through this section. The key is that you setup your configuration parameters to exactly match the SPI Master's (BeagleBone) settings. If you confirm you configuration is correct the next step will be to check that all the clock configurations are also set correctly (see Clock Stop Mode in TRM Document linked above). Review these and let me know if your problem persists. If so, Please post the configuration code using the Code Insert function and we can take a look and see whats going on. 

    Respectfully,

  • After re-reading your question on MDR and MDX I realize I answered the wrong question. Unfortunately, you will not be able to switch the functions of these two I/O's as they are set internally for the McBSP module.
  • Hey Cédric,

    See the following definitions found in the McBSP.h and McBSP.c respectively:



    //***************************************************************************** // //! Configures McBSP in SPI slave mode //! //! \param base is the base address of the McBSP module. //! \param ptrSPISlaveMode is a pointer to a structure containing SPI //! parameters McBSP_SPISlaveModeParams. //! This function sets up the McBSP module in SPI slave mode.The following are //! valid values and ranges for the parameters of the McBSP_SPISlaveModeParams. //! - \b loopbackModeFlag - true for digital loop-back //! false for no loop-back //! - \b clockStopMode - MCBSP_CLOCK_SPI_MODE_NO_DELAY or //! MCBSP_CLOCK_SPI_MODE_DELAY //! - \b wordLength - MCBSP_BITS_PER_WORD_x , x = 8,12,16,20,24,32 //! - \b spiMode It represents the clock polarity and can take //! values: //! - MCBSP_RX_POLARITY_FALLING_EDGE or //! MCBSP_RX_POLARITY_RISING_EDGE //! //! \return None. // //*****************************************************************************



    //*****************************************************************************
    //
    // McBSP_configureSPISlaveMode
    //
    //*****************************************************************************
    void
    McBSP_configureSPISlaveMode(uint32_t base,
                                const McBSP_SPISlaveModeParams* ptrSPISlaveMode)
    {
    
        //
        // Configure clock stop mode.
        //
        if(((ptrSPISlaveMode->clockStopMode) == MCBSP_CLOCK_SPI_MODE_NO_DELAY) ||
           ((ptrSPISlaveMode->clockStopMode) == MCBSP_CLOCK_SPI_MODE_DELAY))
        {
            //
            // Set SPI mode.
            //
            McBSP_setClockStopMode(base,
                              (McBSP_ClockStopMode)ptrSPISlaveMode->clockStopMode);
            //
            // Set loop back mode.
            //
            if(ptrSPISlaveMode->loopbackModeFlag)
            {
                McBSP_enableLoopback(base);
            }
            else
            {
                McBSP_disableLoopback(base);
            }
    
            //
            // Configure module as Slave. MCLKX pin acts as input slave
            // clock and is driven externally by SPI master.
            //
            McBSP_setTxClockSource(base, MCBSP_EXTERNAL_TX_CLOCK_SOURCE);
    
            //
            // Set the input slave clock polarity.
            //
            McBSP_setTxClockPolarity(base,
                                  (McBSP_TxClockPolarity)ptrSPISlaveMode->spiMode);
    
            //
            // Set internal clock (LSPCLK) as SRG clock source. SRG is used to
            // synchronize McBSP logic with externally generated master clock.
            //
            McBSP_setRxSRGClockSource(base, MCBSP_SRG_RX_CLOCK_SOURCE_LSPCLK);
    
            //
            // Assign a clock divider value of 1 for generating CLKG.
            //
            McBSP_setSRGDataClockDivider(base, 1U);
    
            //
            // Set FSX as an input which is driven by slave-enable signal
            // from SPI master.
            //
            McBSP_setTxFrameSyncSource(base, MCBSP_TX_EXTERNAL_FRAME_SYNC_SOURCE);
    
            //
            // Set the polarity for FSX pin as active low.
            //
            McBSP_setTxFrameSyncPolarity(base,
                                         MCBSP_TX_FRAME_SYNC_POLARITY_LOW);
    
            //
            // Disable dual phase mode.
            //
            McBSP_disableTwoPhaseTx(base);
    
            //
            // Set the data format for transmission & reception..
            //
            McBSP_setTxDataSize(base, MCBSP_PHASE_ONE_FRAME,
                           (McBSP_DataBitsPerWord)ptrSPISlaveMode->wordLength, 0U);
            McBSP_setRxDataSize(base, MCBSP_PHASE_ONE_FRAME,
                           (McBSP_DataBitsPerWord)ptrSPISlaveMode->wordLength, 0U);
    
            //
            // Set zero bit data delay for transmission & reception.
            //
            McBSP_setTxDataDelayBits(base, MCBSP_DATA_DELAY_BIT_0);
            McBSP_setRxDataDelayBits(base, MCBSP_DATA_DELAY_BIT_0);
        }
    }

    The values you mentioned (SPI_PROT_POLxPHAx) are only used by the SPI module found in the device not the McBSP module. You can make the McBSP module match however using the above configurations. Below you will find an explanation of the different values for SPI_PROT_POLxPHAx, found in the spi.h file of the c2000 driverlib.

    //*****************************************************************************
    //
    //! Values that can be passed to SPI_setConfig() as the \e protocol parameter.
    //
    //*****************************************************************************
    typedef enum
    {
        //! Mode 0. Polarity 0, phase 0. Rising edge without delay.
        SPI_PROT_POL0PHA0   = 0x0000U,
        //! Mode 1. Polarity 0, phase 1. Rising edge with delay.
        SPI_PROT_POL0PHA1   = 0x0002U,
        //! Mode 2. Polarity 1, phase 0. Falling edge without delay.
        SPI_PROT_POL1PHA0   = 0x0001U,
        //! Mode 3. Polarity 1, phase 1. Falling edge with delay.
        SPI_PROT_POL1PHA1   = 0x0003U
    } SPI_TransferProtocol;

    Respectfully,