9 years, 12 months ago.

LPC1768 I2C frequency

The I2C frequency command does not seem to be working. I have tried both of the available I2C ports, neither increase or decrease in frequency works. Always get 100kHz.

Firmware = mbedmicrontroller_141212.if

  1. include "mbed.h" DigitalOut myled1(LED1); int address = 0x10; char data1[] = {0x01, 0x0C}; char data2[] = {0x02, 0x4C}; int main(void) { I2C i2c(p28, p27); i2c.frequency(400000); while(1) { i2c.write(address, data1, 2); myled1 = 0; wait(0.2); i2c.write(address, data2, 2); myled1 = 1; wait(0.2); } }

1 Answer

9 years, 11 months ago.

First of all, please use code tags (<<code>> and <</code>>). That makes your code both readable and copy-pasteable.

Now I checked your code with a logic analyzer and it nicely gave a (roughly) 400kHz output. (Definately not 100kHz).

Options: First of all, is your mbed lib up to date? Click on it in the online compiler, check if at the right side there is an update button. Are you resetting your mbed after loading the new bin? Are you sure you are loading a new bin to the mbed, and not for example another drive?

Accepted Answer

Hi Erik, Many thanks. It was the revision of mbed on the online compiler. Once I had right clicked on mbed pressed the update option and recomplied, all now works. :-) Will use the code tags in future.

posted by James Poulter 13 May 2014