- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I try to use a sensor MPU5060 in I2C but I get some trouble.
In my memories it easy to use I2C with PsoC but It doesn't work 😞
My device adresse is 0x68;
I define uint8 test=0x43; which is the adresse of MPU6050_GYRO_XOUT_H_REG
and uint8 userArray[10]={0,0,0,0,0,0,0,0,0,0};
After designed the .CYSCH I write on my code:
I2C_1_Start();
while(1){
I2C_1_MasterClearStatus();
2C_1_MasterWriteBuf(MPU6050_ADDRESS , &test, 1, I2C_1_MODE_COMPLETE_XFER );
while (I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP);
CyDelay(10);
I2C_1_MasterClearStatus();
I2C_1_MasterReadBuf(MPU6050_ADDRESS , userArray, 1,I2C_1_MODE_COMPLETE_XFER );
while (I2C_1_MasterStatus() & I2C_1_MSTAT_XFER_INP);
CyDelay(10);
val = ((int)userArray[0])*256 + (int)userArray[1];
sprintf(buf, "userArray\t%d\t%d\t%d\t%d\n\r",(int)userArray[0],(int)userArray[1], val, (int)test) ;
}
But It returns nothing 😞
Thank you
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1) This line of code 2C_1_MasterWriteBuf(MPU6050_ADDRESS , &test, 1, I2C_1_MODE_COMPLETE_XFER ); is missing
the "I" at beggining of line, eg. should be I2C_.......
2) Pull ups installed on SDFA and SCL ?
3) On scope levels and timing look right for speed ?
4) userArray is long enough + 1 for the null character to terminate string ?
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This 2) Pull ups installed on SDFA and SCL ? should read this 2) Pull ups installed on SDA and SCL ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yep sorry I forgot teh "I" when I copied/pasted my code...
There are already resistor on the board of the mpu5060
and for the speed I choose 100K like the datasheet... :'(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For most I2C-devices the first write to specify which register to read from has to be made with No_Stop and the reading with Repeat_start. I personally prefer the more basic functions SendStart(), WriteByte(), SendRestart(), ReadByte and SendStop() in that order.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have seen this site, it has code possibly you could port -
http://www.i2cdevlib.com/devices/mpu6050#source
Regards, Dana.