using the provided libraries and the provided application example ,i have not been able to get the I2C to work correclty. I've created a seperate project to test the I2C and alas I can't seem to see any clock pulses being generated on my scope. Connected to the module i have an RS-EDP unit which has both a serial latch and serial 24LC32 EEPROM attached to it. The I2C is pulled up on the base board to 3.3V.
When itry to communicate with I2C packets to either of the device i get a series of error reported on the RS232 output.
I2C Start Write - returned incorrect status 0x20 in i2C::Write
The clock seems to be in the low state and only rises to 3.3V during th erest and programming phase. The data line remains at 3.3V and does not out put any data.
Are there any known problems with the I2C library ?
I notice also the I2C functions do not provide an ACK/NACK return, so its not possible to ping a device to see if its connected for example.
After the first I2C write i should expect to see some clock and data signals on the scope. When i remove the MBED module both lines return to 3.3V which would suggest there is no short circuit on my hardware.
below is the code.
#include "mbed.h"
I2C i2c(9, 10);
Serial pc(USBTX, USBRX);
const int addr = 0x70; // define the I2C Address
int main() {
char cmd[2];
while(1) {
cmd[0] = 0x0; // pointer to command register
cmd[1] = 0x51; // Start ranging, results in cm
i2c.write(addr, cmd, 2); // Send command string
wait(0.07); // Could also poll, 65ms is typical
// Set pointer to location 2 (first echo)
cmd[0] = 0x2;
i2c.write(addr, cmd, 1);
i2c.read(addr, cmd, 2); // read the two-byte echo result
// print the ranging data to the screen
float echo = 0.01 * ((cmd[0] << 8) + cmd[1]);
pc.printf("Range = %.2f\n", echo);
wait(0.1);
}
}
Best Regards
David Giles
using the provided libraries and the provided application example ,i have not been able to get the I2C to work correclty. I've created a seperate project to test the I2C and alas I can't seem to see any clock pulses being generated on my scope. Connected to the module i have an RS-EDP unit which has both a serial latch and serial 24LC32 EEPROM attached to it. The I2C is pulled up on the base board to 3.3V.
When itry to communicate with I2C packets to either of the device i get a series of error reported on the RS232 output.
I2C Start Write - returned incorrect status 0x20 in i2C::Write
The clock seems to be in the low state and only rises to 3.3V during th erest and programming phase. The data line remains at 3.3V and does not out put any data.
Are there any known problems with the I2C library ?
I notice also the I2C functions do not provide an ACK/NACK return, so its not possible to ping a device to see if its connected for example.
After the first I2C write i should expect to see some clock and data signals on the scope. When i remove the MBED module both lines return to 3.3V which would suggest there is no short circuit on my hardware.
below is the code.
#include "mbed.h"
I2C i2c(9, 10);
Serial pc(USBTX, USBRX);
const int addr = 0x70; // define the I2C Address
int main() {
char cmd[2];
while(1) {
cmd[0] = 0x0; // pointer to command register
cmd[1] = 0x51; // Start ranging, results in cm
i2c.write(addr, cmd, 2); // Send command string
wait(0.07); // Could also poll, 65ms is typical
// Set pointer to location 2 (first echo)
cmd[0] = 0x2;
i2c.write(addr, cmd, 1);
i2c.read(addr, cmd, 2); // read the two-byte echo result
// print the ranging data to the screen
float echo = 0.01 * ((cmd[0] << 8) + cmd[1]);
pc.printf("Range = %.2f\n", echo);
wait(0.1);
}
}
Best Regards
David Giles