how to configure a I2C in MCB1700 with LPC1758?
I have a MCB1700 board with LPC1758, I am trying to use the I2C on it as a master to run a ultrasonic sensor srf08.
How should I configure the I2C setting on the LPC1758?
Sorry I am a bit confuse right now.
For the I2C write to Sensor
I2CWriteLength[PORT_USED] = 3; //writelength=3 because 1 for sensor_addr(0xE8), 1 for 0x00 and 1 for0x51 right?
I2CReadLength[PORT_USED] = 0; //readlength=0 because it is write only
I2CMasterBuffer[PORT_USED][0] = sensor_addr; //first port is sensor addr telling the i2c what the sensor addr is
I2CMasterBuffer[PORT_USED][1] = 0x00; //second port is command register
I2CMasterBuffer[PORT_USED][2] = 0x51; //command for sensor start in range cm
I2CEngine( PORT_USED ); //I2CEngine do the scheduling
Do I need a delay after write and then do a read 1 byte from sensor?
I2CWriteLength[PORT_USED] = 0; //writelength=0 because read only
I2CReadLength[PORT_USED] = 1; //read 1 byte only
I2CMasterBuffer[PORT_USED][0] = sensor_addr; //telling the i2c what the sensor addr is
while ( 1 ); //loop forever
}
So the byte read from the sensor will be in the masterbuffer?
Sorry for having so many question, it is because this is my first to write a program and learn a I2C!
And thank you for you being patient to me
I was away from computers for a while.
Have you tried the software you wrote? That would be the best way to see if it works or not...
You can also add an oscilloscope on the line and see what is being sent.
I have used I²C a lot but I haven't used this NXP I²C module or that driver.