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.

TM4C1230Hxx I2C1 interface with MPU9150

Other Parts Discussed in Thread: TM4C1230H6PM

Hi1

Can any one told me whats wrong with initialization of I2C1 interface?

Device: TM4C1230H6PM Interface with MPU9150 ( I2C:  Addr: 0x69)

Interface: I2C1 ( PA6 : I2C1 SCL, PA7: I2C1 SDA)

Data rdy pin of MPU9150 : PORTF, PIN0

Platform: Keil5

PC: interface Hyper Terminal (UART0, BR, 115200)

We want to interface MPU9150 on I2C1 of TM4C1230H6PM, for the same ref. we have gone through the tiva sample codes.  and initialize the I2C1 PORT as well as MPU9150Init.

void InitializeI2C(void)
{

    // Must be Enable I2C1 & associated GPIO ports before used

        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); // Select PORT A Pin6, 7 for I2C1                                                          
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);//                                                                                                                                                                                                                           
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);// Used PORTF, Pin0 for Sensor Interrupt                                         

        // Configure the pin muxing for I2C1 functions on port A6 and A7.

        ROM_GPIOPinConfigure(GPIO_PA6_I2C1SCL);                                                                                                                                            
        ROM_GPIOPinConfigure(GPIO_PA7_I2C1SDA);                                                                                                                                            

        // Select the I2C function for these pins.  This function will also
        // configure the GPIO pins pins for I2C operation, setting them to
        // open-drain operation with weak pull-ups.  Consult the data sheet
        // to see which functions are allocated per pin.

        ROM_GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);                                                                                                                     
        ROM_GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);  

        // Configure and Enable the GPIO interrupt. Used for INT signal from the MPU9150

        ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);                                                                                                              
        GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0);                                                                                                                                   
        ROM_GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);                                                                                     
        ROM_IntEnable(INT_GPIOF);                
        
        // Enable interrupts to the processor.

        ROM_IntMasterEnable();    

        // Initialize I2C1 Peripheral

        I2CMInit(&g_sI2CInst, I2C1_BASE, INT_I2C1, 0xff, 0xff, MAP_SysCtlClockGet());                                                                 
        UARTprintf("\nI2CM_Init!!!\n");

        // Initialize the MPU9150 Driver.
        
    MPU9150Init(&g_sMPU9150Inst, &g_sI2CInst, MPU9150_I2C_ADDRESS, MPU9150AppCallback, &g_sMPU9150Inst);
        
        UARTprintf("\nMPU9150Init!\n");                
                                
    // Wait for transaction to complete
    MPU9150AppI2CWait(__FILE__, __LINE__);
        
        UARTprintf("\nWait for Transaction!\n");

    // Write application specifice sensor configuration such as filter settings and sensor range settings.

    g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_94_98;
        g_sMPU9150Inst.pui8Data[1] = MPU9150_GYRO_CONFIG_FS_SEL_250;
    g_sMPU9150Inst.pui8Data[2] = (MPU9150_ACCEL_CONFIG_ACCEL_HPF_5HZ | MPU9150_ACCEL_CONFIG_AFS_SEL_2G);
    MPU9150Write(&g_sMPU9150Inst, MPU9150_O_CONFIG, g_sMPU9150Inst.pui8Data, 3, MPU9150AppCallback, &g_sMPU9150Inst);
    
    // Wait for transaction to complete

    MPU9150AppI2CWait(__FILE__, __LINE__);

    // Configure the data ready interrupt pin output of the MPU9150.
    g_sMPU9150Inst.pui8Data[0] = MPU9150_INT_PIN_CFG_INT_LEVEL | MPU9150_INT_PIN_CFG_INT_RD_CLEAR | MPU9150_INT_PIN_CFG_LATCH_INT_EN;
                                                                
    g_sMPU9150Inst.pui8Data[1] = MPU9150_INT_ENABLE_DATA_RDY_EN;
        
        MPU9150Write(&g_sMPU9150Inst, MPU9150_O_INT_PIN_CFG, g_sMPU9150Inst.pui8Data, 2, MPU9150AppCallback, &g_sMPU9150Inst);

    // Wait for transaction to complete

    MPU9150AppI2CWait(__FILE__, __LINE__);

        UARTprintf("\nMPU9150 Configure successful!!!\n");   // for MPU9150 Config Test         
}
 and ISR :

void IntGPIOf(void)        
{    
        unsigned long ulStatus;
    
      ulStatus = GPIOIntStatus(GPIO_PORTF_BASE, true);                                                                        

        // Clear all the pin interrupts that are set
 
        GPIOIntClear(GPIO_PORTF_BASE, ulStatus);                                                                                                                                                                                
    
     // MPU9150 Data is ready for retrieval and processing.
   
        if(ulStatus & GPIO_PIN_0)                                                                                                                                                                                                                
        {
            MPU9150DataRead(&g_sMPU9150Inst, MPU9150AppCallback, &g_sMPU9150Inst);
        }
}

Startup file :

;***************************************************************************************
; External declaration for the interrupt handler used by the application.
;****************************************************************************************

        EXTERN  IntGPIOf                ;   for MPU9150
            
        EXTERN  MPU9150I2CIntHandler

;***************************************************************************************
; The vector table.
;****************************************************************************************

EXPORT  __Vectors
__Vectors

      DCD     IntGPIOf                    ; GPIO Port F   

;***************************************************************************************

Pls suggest any changes which requires to run the MPU9150. We did all above said changes but result is not in favor. The code is stuck up somewhere in the function of transaction "MPU9150AppI2CWait(__FILE__, __LINE__);"

Thanks in advance

Pramod

  • Hi Pramod,

        See, my signature below, regarding PF0.

    edited . . .

        Also, see "Common GPIO Problem" sticky post in this forum.

    -kel

  • Doubtful that PF0 alone - destroys I2C1 operation.  Thus - likely there's more to this puzzle.

    More troubling - this MCU-Accessory board combination has appeared - this space - several times.  Did not the code originator "catch" the unfortunate "default" suffered upon PF0?  (i.e. avoid that pin like the plague)  If instead - poster chose that pin, "on his own" - then the blessings of failure to, "RTFM" are well deserved - poetic...

    Ms. Cozart's recent (yesterday) sticky post - and your "signature" both represent, "way too subtle" a means to sound the NMI alert - do you not agree?   Launchpad brigades gotta "launch" (that's the point - right?)  - little care/time for, "forum only, hidden/suppressed" MCU usage cautions... Are face-saving, baby steps, appropriate when child wanders into highway traffic?

    Bold - Page 1 - "MCU Cautons Listing" - each/every MCU Manual - may enjoy much better chance of, "some notice/compliance."  (how - ever - will users "blunder" into your, "signature?")  And - are rushed users likely to read your post to its bitter end - where enlightenment (this narrow issue) resides?

    Unfathomable why this vendor allows this long known misfortune to so painfully persist,,,  Seems an effective "counter" to the highly advertised/represented "launch" concept - does it not?  {thru the static...overheard (14MHz band)... Houston: "We have ignition!")    Yet some way/how - capsule's unable to, clear the tower!   NMI thus sullies yet another, "launch!"  (some suggest "limp" - while NMI + dreadful, 0-ohm R placements - continue their mayhem...)  Those 0-ohm Rs (yielding MCU "pin to pin" shorting!)  - clearly should have been 'bagged" - left for user to "elect" their use/placement...

    [added] note that o.p. had time/energy to create logo - yet little/none for, RTFM...  (aka "NMI's mice-type/camouflage alert", w/in GPIO section...

  • Thanks Kel & Cb1,

    Let me change the interrupt PIN PF0 of MPU9150.

    Pramod

  • Hi!

    Now, I used PB7 : for data ready INTR PIN for MPU9150.

    Still problem is persist, don't know why my I2C1 is not getting any result from sensor.

    Somebody can suggest me what exactly wrong in the I2C setup as well as MPU setup using API functions call of Tiva lib.

    Thanks in advance

    Pramod

  • Hello Pramod,

    Instead of using the MPU9150 Call, can you instead use the TIVAWare i2c.h/.c files and construct the code if the other code is not working? This will help isolate the issue to a mpu9150 API incorrect usage?

    I do understand it would be an effort but will get you going faster.

    Regards

    Amit

  • Thanks, problem solved!

    found the issue in startup file ( Intr Handler for I2C1) :

    DCD        MPU9150I2CIntHandler        ; I2C1 Master and Slave    

    Thanks

    pramod      

  • I have the same issue, could you elaborate on the solution? I am trying to use the 9150 code in a 9250 module but I am stuck on MPU9150AppI2CWait(__FILE__, __LINE__);