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.

RTOS/MSP432P401R: having a timeout when working in SPI Slave mode?

Part Number: MSP432P401R

Tool/software: TI-RTOS

I'm using the source code provided in TIDEP-0091.

In that one, MSP432P401R SPI is used in Slave mode to communicate with IWR1443 (working as SPI master). 

When there's no data coming from IWR1443 (Master), MSP432P401R SPI hangs forever.

the msp_spi.c file of TIDEP-0091 uses following init of SPI

/* Initialize SPI handle in slave mode */
    SPI_Params_init(&spiParams);
    spiParams.mode = SPI_SLAVE;
    spiParams.frameFormat =  SPI_POL0_PHA0;
//    spiParams.frameFormat =  SPI_POL1_PHA1;
//    spiParams.transferMode = SPI_MODE_CALLBACK;         
//    spiParams.transferCallbackFxn = spiTransferCompleteCallback; 
    spiParams.transferMode = SPI_MODE_BLOCKING; //comment
    spiParams.transferTimeout = SPI_WAIT_FOREVER; //comment
    spiParams.bitRate  = 1000000;
    spiParams.dataSize = 16;

When I change SPI_WAIT_FOREVER to a number value, still the function waits forever for SPI data.

I checked the "ti/simplelink_msp432_sdk1_40_01_00/source/ti/drivers/spi.h"   and it says "Transfer timeout in system ticks (Not supported with all implementations" as below.

typedef struct SPI_Params_ {
    SPI_TransferMode transferMode;       /*!< Blocking or Callback mode */
    uint32_t         transferTimeout;    /*!< Transfer timeout in system
                                              ticks (Not supported with all
                                              implementations */
    SPI_CallbackFxn  transferCallbackFxn;/*!< Callback function pointer */
    SPI_Mode         mode;               /*!< Master or Slave mode */
    uint32_t         bitRate;            /*!< SPI bit rate in Hz */
    uint32_t         dataSize;           /*!< SPI data frame size in bits */
    SPI_FrameFormat  frameFormat;        /*!< SPI frame format */
    void            *custom;             /*!< Custom argument used by driver
                                              implementation */
} SPI_Params;

Is it possible to implement a timeout for SPI slave mode here? if could someone point out how  to impelment the timeout for SPI slave transaction please?

cheers

Randy

  • 
    

    Randy,
    I would recommend updating to the latest SDK which does not include that limitation.

    C:\ti\simplelink_msp432p4_sdk_2_10_00_14\source\ti\drivers\spi

    /*!
     *  @brief SPI Parameters
     *
     *  SPI Parameters are used to with the SPI_open() call. Default values for
     *  these parameters are set using SPI_Params_init().
     *
     *  @sa         SPI_Params_init()
     */
    typedef struct SPI_Params_ {
        SPI_TransferMode transferMode;       /*!< Blocking or Callback mode */
        uint32_t         transferTimeout;    /*!< Transfer timeout in system
                                                  ticks */
        SPI_CallbackFxn  transferCallbackFxn;/*!< Callback function pointer */
        SPI_Mode         mode;               /*!< Master or Slave mode */
        uint32_t         bitRate;            /*!< SPI bit rate in Hz */
        uint32_t         dataSize;           /*!< SPI data frame size in bits */
        SPI_FrameFormat  frameFormat;        /*!< SPI frame format */
        void            *custom;             /*!< Custom argument used by driver
                                                  implementation */
    } SPI_Params;


    Regards,
    Chris

  • Hi Chris,

    Thanks for the reply.

    I downloaded and installed SimpleLink MSP432p4 SDK 2.1.0.

    I'm using the source code provided in TIDEP-0091 and when I build the source with SimpleLink MSP432 SDK 1.6.0 it didn't work.
    The discussion regarding that is here : e2e.ti.com/.../664060

    As a solution, I was asked to use SDK 1.4.1 and it was working well.

    Now when I use SimpleLink 2.1.0 to build TIDEP-0091 MSP342 project, the project builds without an issue.
    I modified the source to start SPI comms by pressing the S2 button. As soon as I press button S2 (when the MSP432 starts SPI comm, I guess SPI causes the issue as this button press doesn't do anything else), the following exception occurs :

    [CORTEX_M4_0] ti.sysbios.family.arm.m3.Hwi: line 1148: E_hardFault: FORCED
    ti.sysbios.family.arm.m3.Hwi: line 1225: E_busFault: PRECISERR: Immediate Bus Fault, exact addr known, address: ed200104
    Exception occurred in background thread at PC = 0x0000c4aa.
    Core 0: Exception occurred in ThreadType_Task.
    Task name: {unknown-instance-name}, handle: 0x20009bb0.
    Task stack base: 0x20008a00.
    Task stack size: 0x200.
    R0 = 0x310000d2 R8 = 0x00000001
    R1 = 0x00000000 R9 = 0xffffffff
    R2 = 0x20009d3c R10 = 0x00000015
    R3 = 0x000604e3 R11 = 0xffffffff
    R4 = 0x00000001 R12 = 0x00000020
    R5 = 0x00000000 SP(R13) = 0x20008b68
    R6 = 0x00000000 LR(R14) = 0x00001b95
    R7 = 0xed2000fc PC(R15) = 0x0000c4aa
    PSR = 0xa1000000
    ICSR = 0x00418803
    MMFSR = 0x00
    BFSR = 0x82
    UFSR = 0x0000
    HFSR = 0x40000000
    DFSR = 0x00000001
    MMAR = 0xed200104
    BFAR = 0xed200104
    AFSR = 0x00000000
    Terminating execution...

    I suspect, the SDK 2.1.0 causes the issue as SDK 1.4.1 works with TIDEP-0091 without an issue.

    Do you have any clues why this exception occurs? If so any suggestions to fix it?

    I really need the SPI Slave timeout functionality.
    If this SDK 2.1.0 does not work with TIDEP-0091, is there any possibility to implement the SPI Slave timeout on SDK v. 1.4.1?

    cheers,
    Randy

  • Randy,

       This is more involved than I anticipated.  I have attached what I did to make the code build with the latest SDK, but I am not clear as to the changes that you made to add a GPIO and associated HWI.  Please let me know if what I have provided makes sense and/or if you have any code that you can share.

    Chris

    level_sense_demo.zip

  • Randy,
    Since you have not replied, I will mark as resolved. If this is not resolved, then please respond accordingly. If you have additional questions, then please start a new thread using the "Ask a related question" or "Ask a new question" buttons.

    Regards,
    Chris

**Attention** This is a public forum