I need help from a smart guy, I'm real frustrated.
Problem-I can't seem to get an MPU-6050 (DFRobot SEN0142) to talk back, or talk at all. Do I need to, somehow, initialize the 6050 first? Does the 6050 wake up at 400 kHz I2C speed?
Goal-I am just trying to read who_am_i register as a learning experience. I think I need to; S, 0x68+W,check ACK, 0x75, check ACK, S, 0x68+R, check ACK, read who_am_i, send NACK, P (per pg. 37 of PS-MPU-6000A-00).
Background- Using an older Microchip PICDEM 2 Plus board with PIC18F4520. Watching I2C bus with Saleae Logic4 (very cool gizmo) as I2C bus analyzer. Tried bus speeds from 100 kHz to 430 kHz with same result (NAK).
FYI- I am not a great C coder, code excerpts (using Microchip XC8/netbeans environment);
int Accel_Addr=0x68; //J1 is soldered, thus MPU6050_Addr=0x68 (tried 0x69 too)
//I2C setup
TRISC=0b00011000;
LATC=0x00;
SSPADD=0x03; //0x03=353kHz,0x11=100kHz, measured w/Logic4
SSPSTAT=0x00;
SSPCON1=0x28; //I2C Enable SSPEN=1, Master mode
//Begin I2C transfer
IdleI2C(); //Test for I2C idle
StartI2C(); //Sets start bit and then
WaitI2C(); //waits for SSPIF=0 to continue
//Write byte AD+W
SSPBUF=(Accel_Addr); //Tx MPU address and bit7=0 for I2C write
WaitI2C(); //I clearly see a 0x68 and a NAK with the I2C bus analyzer here
//Wait for ACK
while (SSPCON2bits.ACKSTAT); //******Code stops here because I don't get ACK (get NAK) then silence on the bus*****
my code continues for reading the who_am_i RA but it never gets there, so I didn't include it.
*******HELP********