I have created 3 I2c channels and am looking to change the default clock speed to different frequencies on each channel. I have initialised all 3 channels and am able to see the device on the bus, write to registers etc.
On the SAMD21 the Wire library setClock() function uses the following formula, to calculate the value in the I2C sercom's 8-bit BAUD register from the specified baud rate (clock speed):
Thank you for getting back to me, so from the information you have provided, it looks like I can change the I2C clock from 10kHz to 3MHz. Was not aware of the formula you provided good to know.
That answers my first question but I'm still a bit lost with
TwoWire I2C_CH1.setClock(10000);
Will not compiling "error: expected initializer before '.' token" not sure what I'm missing
The formula means that using the default Wire (or TwoWire) configuration, it's not possible to go below 100kHz. Therefore the following line of code correctly sets the SCL clock to 100kHz:
TwoWire I2C_CH1.setClock(100000);
...whereas attempting to set the SCL clock to 10kHz, doesn't work:
TwoWire I2C_CH1.setClock(10000);
...this is because the forumula generates a number too large for the SERCOM's 8-bit BAUD register.
The error is most likely a syntax error somewhere in your code.