KEA 128 I2C Help!!!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KEA 128 I2C Help!!!

1,453 Views
maharajshreekum
Contributor III

Hi all,

i ma trying to run I2C on kea 128 development board. the module which i am testing is I2C0 and the slave device being addressed is MPU IMU 9DOF.

I have done the mandatory setting required for configuring the i2c bus ,like the pin selection, clock rate and all,but i am not able to see anything on DSO of SDA or SCL pin. No clock generation is being done when i am doing some transaction on i2c bus.  

 

I am using the I2C driver for KEA which have the necessary function for starting the I2C and configuring it for talking to a slave device. 

 

I2C_ConfigType i2c_test;      //object to I2C config struct in i2c.h

main()

{

/***I2C (100Khz) Configuration for Current sensor****/

SIM_PINSEL0 &= ~SIM_PINSEL_I2C0PS_MASK; //map i2c0 pins on PTA3,SCL and PTA2,SDA
i2c_test.u16F = 0x1E; //I2C baud rate = I2C module clock speed (Hz)/(mul × SCL divider) = 20Mhz/(1x192)
i2c_test.u16OwnA1 = 0x68; //slave address
i2c_test.sSetting.bI2CEn = 0x01;

I2C_Init(I2C0,&i2c_test);

while(1)
{
I2C_Start(I2C0);
I2C_WriteOneByte(I2C0,0x75);         //read WHO_AM_I reg of IMU slave
I2C_ReadOneByte(I2C0,&i2c_rd,1);
Uart_SendChar(i2c_rd);
Uart_SendChar(0x0D);
I2C_Stop(I2C0);


LED0_ON;
delay_ms(500);
LED0_OFF;
delay_ms(500);
}

}   

I have also attached the I2C drivers for ready reference>>>>>

when i run this code, nothing comes in uart port and led also doesn't blink.  But if I disable all the I2C related functions, code runs perfect.Where am I going wrong.?????

HELP!!!!!!!!!!!

Thanks

Original Attachment has been moved to: iic.7z.zip

Labels (1)
Tags (1)
0 Kudos
2 Replies

837 Views
Jonathan_Iglesias
NXP TechSupport
NXP TechSupport

Dear Maharaj Shree Kumar Sood,

I apologize for the delay, please check this projects are for bareboard. you will just have to chance little things to make it works in your board.

best regards.

Jonathan

0 Kudos

837 Views
maharajshreekum
Contributor III

HI Jonathan Iglesias,

Thanks for the i2c files. They were of great help to me for cross checking my builtin i2c functions. Now i have written the code for reading a register from IMU with the help of your .h and .c files. But , the choke is that I am unable to see and clock on my SCL pin on DSO.

SIM_PINSEL1 &= 0x0000; //map i2c1 pins on PTE1,SCL and PTE0,SDA

i2c_test.u16F = 0x1E;       //I2C baud rate = I2C module clock speed (Hz)/(mul × SCL divider) = 20Mhz/(1x192)
//i2c_test.u16OwnA1 = SLAVE_ADRESS; //slave address
i2c_test.sSetting.bI2CEn = 0x01;

I2C_Init(I2C1,&i2c_test);


while(1)
{
I2C_start();
I2C1_D = SLAVE_ADRESS << 1; /* Send I2C device address with W/R bit = 0 */
I2C_wait();
I2C1_D = MPU_WHO_AM_I;
I2C_repeatedStart();
I2C0_D = (SLAVE_ADRESS << 1) | 0x01; /* Send I2C device address this time with W/R bit = 1 */
I2C_wait();

I2C_enterRxMode();
I2C_disableAck();

i2c_rd_1 = I2C1_D;
I2C_wait();
I2C_stop();
i2c_rd_1 = I2C1_D;
Delay(50);
sprintf(str,"Reg val = %d",i2c_rd_1);
Uart_SendStr(str);
}

I think the problem is that my i2c is not getting configured properly on these pins. Although the pins on the sensor side are pulled up with 10k to 3.3V. 

So, i think i am doing somewhere wrong with I2c configuration.

Please help....

0 Kudos