Minimum I2C speed for Teensy3.2 with Teensyduino?

Status
Not open for further replies.

dlchambers

Well-known member
What's the minimum speed supported by Wire.setClock() for a Teensy 3.2 running at the std 72 MHz?

I have an I2C issue that I'm trying to debug and want to slow it waaaaaay down to observe things.

Also, are the standard increments? I.e. clock rate should be a multiple of X ?

Thanks!
-Dave
 
You might try the Teensy version? I didn't look into wire but in the current i2c_t3.h I find these listed speeds:

enum i2c_rate {I2C_RATE_100 = 100000,
I2C_RATE_200 = 200000,
I2C_RATE_300 = 300000,
I2C_RATE_400 = 400000,
I2C_RATE_600 = 600000,
I2C_RATE_800 = 800000,
I2C_RATE_1000 = 1000000,
I2C_RATE_1200 = 1200000,
I2C_RATE_1500 = 1500000,
I2C_RATE_1800 = 1800000,
I2C_RATE_2000 = 2000000,
I2C_RATE_2400 = 2400000,
I2C_RATE_2800 = 2800000,
I2C_RATE_3000 = 3000000};
 
No, they are separate.

Take a look at the sources to Wire.cpp which is installed with your Teensyduino (xxx\hardware\teensy\avr\libraries\Wire\Wire.cpp). if you look at the setClock, the code sort of looks like it has a minimum of somewhere near 100khz

In cases like this my two suggestions are: You can look at the manual: http://www.pjrc.com/teensy/K20P64M72SF1RM.pdf section 46

And what have you tried? What happens if you ask for 1000?
 
The I2C clock rate is configured from the F_BUS speed divided by mult*icr in the I2Cx_F register (ref manual ch 46). you also would need to configure stop and hold times. the Wire library and i2c_t3 library provide a fixed set of I2C clock rates to choose from (usually starting at 100khz). If you wanted something slower, you'll need to manipulate the registers accordingly.

a logic analyzer can be very helpful, https://www.saleae.com/

EDIT
if you're brave you could also try "software I2c", bit-bang any two pins of your choice, e.g. Arduino example:
https://github.com/todbot/SoftI2CMaster It is AVR-specific. I ported the old maple leaflabs Wire library to teensy 3. That bit-bang library uses OPEN DRAIN pinMode with digitalRead/Write
 
Last edited:
Status
Not open for further replies.
Back
Top