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.

SPI interfacing with MPU-9250 with "TM4C1294NCPDT launch board" or "MSP432"

Other Parts Discussed in Thread: TM4C1294NCPDT, TM4C123GH6PM

Hi everyone,

I have "MPU 9250 IMU sensor" ,i want to  do SPI interface this sensor with either "TM4C1294ncpdt controller " or " MSP432" controller .

CAn anyone guide me how to interface both of them.

i want to collect the data from "MPU-9250 sensor" and i have to store it,please anyone can guide me or can anyone give me "Code snippet" if any one has....

Thank you

  • Hello Rahul,

    Sure. Read the specification of the MPU9250 to first understand the SPI protocol requirements. Then use the example code of spi_master.c under TivaWare installation "TivaWare_C_Series-2.1.2.111\examples\peripherals\ssi" to implement the protocol.

    For MSP432, you would need to ask the MSP432 forum. I do not understand what a "code snippet" is, but in this case I would refer to the example in the first para.

    Regards
    Amit
  • Hi Amit,


    i am not able to find code at this place "TivaWare_C_Series-2.1.2.111\examples\peripherals\ssi".i got only Function header files and function defnation.

    As like Hibernate i need complete file for SPi . Is it not avilable?



    Thanks
  • Hello Rahul

    There is a code file. You would need to create a project!! Or you can load any existing project and replace the content of the main code with the ssi_master.c content.

    Regards
    Amit
  • Hi amit

    can u also tell me what protocls requirements i have to study about MPU-9250 to interface with TIVA through SPI..

    Thanks
  • Hello Rahul,

    SPI is a simple synchronous protocol. A wiki read of the protocol would be good document.

    When it comes to interfacing, you need to make sure how the FSS is expected, the max clock rate and the width of the frame in terms of bits need to be correctly programmed to the SSI control registers.

    Regards
    Amit
  • hi amit

    i am not getting anything from MPU-9250 Spi Protocols requirement .i searched a lot.

    actually i want to interface  acclerometer of MPU-9250 with Tm4c1294ncpdt.

    can u please guide me detailly abt SPi interfacing and what are the requirement for MpU-9250 device ,inorder to interface with tiva.

    please

  • Hello Rahul,

    Can you first of all share what you did not get about MPU9250 SPI protocol requirement? Is there a specification document for MPU9250 that you can share?

    Regards
    Amit
  • hi

    i hve one register which are used for identify the device identity called "whoami" register so i that when i send device address so that i shd get the device identity and .
    i connected SCL connection,FSS,tx and rx pin.
    first i want to read the "whoami register" so that i can able to establish spi communication between MPU-9250 with TIVA.
    can u guide me how to do that?


    from data sheet they just given methd of connection of "SCL","FSS","RX" and "TX" how can i do configuration.
  • Hello Rahul,

    Since I do not have access to the specification, can you please share the relevant section of the data sheet

    Regards
    Amit
  • Hello Amit

    I have some problems with the SPI bus (TM4C123GH6PM) and the MPU9250.
    So, Here you have the specs of the MPU9250 for SPI protocol:


    Here my code (SPI init-TM4C, SPI bus selection and read WHOAMI register on MPU9250) 

    void pfcn_MPU9250sensor_InitHW(void)
    {
    	//
    	// Enable GPIO port A which is used for SSI0 pins.
    	//
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	//
    	// The SSI0 peripheral must be enabled for use.
    	//
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    
    	//
    	// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.
    	// This step is not necessary if your part does not support pin muxing.
    	// TODO: change this to select the port/pin you are using.
    	//
    	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    	GPIOPinConfigure(GPIO_PA4_SSI0RX);
    	GPIOPinConfigure(GPIO_PA5_SSI0TX);
    
    	//
    	// Configure the GPIO settings for the SSI pins.  This function also gives
    	// control of these pins to the SSI hardware.
    	// The pins are assigned as follows:
    	//      PA5 - SSI0Tx
    	//      PA4 - SSI0Rx
    	//      PA3 - SSI0Fss
    	//      PA2 - SSI0CLK
    	//
    	GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
    
    	//
    	// Configure and enable the SSI port for SPI master mode.  Use SSI0,
    	// system clock supply, idle clock level low and active low clock in
    	// freescale SPI mode, master mode, 1MHz SSI frequency, and 8-bit data.
    	// For SPI mode, you can set the polarity of the SSI clock when the SSI
    	// unit is idle.  You can also configure what clock edge you want to
    	// capture data on.  Please reference the datasheet for more information on
    	// the different SPI modes.
    	//
    	SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_2,SSI_MODE_MASTER, 100000, 8);
    
    
    	//
    	// Enable the SSI0 module.
    	//
    	SSIEnable(SSI0_BASE);
    
    	//
    	// Read any residual data from the SSI port.  This makes sure the receive
    	// FIFOs are empty, so we don't read any unwanted junk.  This is done here
    	// because the SPI SSI mode is full-duplex, which allows you to send and
    	// receive at the same time.  The SSIDataGetNonBlocking function returns
    	// "true" when data was returned, and "false" when no data was returned.
    	// The "non-blocking" function checks if there is any data in the receive
    	// FIFO and does not "hang" if there isn't.
    	//
    	uint8_t pui32DataRx[8];
    	uint8_t PackageDataCounter;
    	while(SSIDataGetNonBlocking(SSI0_BASE, (uint32_t*)&pui32DataRx[0]))
    	{
    	}
    
    	SysCtlDelay(4000000);
    	SSIDataPut(SSI0_BASE,USER_CTRL);
    	SSIDataPut(SSI0_BASE,0x10);
    
        //
        // Wait until SSI0 is done transferring all the data in the transmit FIFO.
        //
        while(SSIBusy(SSI0_BASE));
        SSIDataPut(SSI0_BASE,WHO_AM_I|READ_FLAG);
        SSIDataPut(SSI0_BASE,0xAA);
    
        PackageDataCounter=0;
        while(SSIDataGetNonBlocking(SSI0_BASE,(uint32_t*)&pui32DataRx[PackageDataCounter]))
    	{
    		PackageDataCounter++;
    	}
    
        while(SSIBusy(SSI0_BASE));
        SysCtlDelay(4);
    }

    I took a glance on the oscilloscope on the SPI lines, I can see all the signals according to SPI config. except for the Rx line, this line is dead. It looks like the MPU9250 is not sending data back to micro.

    Any suggestion?

  • Hello Juan

    Please check if the reset and power to the MPU9250 is correctly applied

    Regards
    Amit