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