Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C Fastmode on lm4f Stellaris #343

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

I2C Fastmode on lm4f Stellaris #343

wants to merge 10 commits into from

Conversation

AxelTB
Copy link

@AxelTB AxelTB commented Mar 16, 2014

I managed to implement FastMode in lm4f devices overloading the function:
void setModule(unsigned long);
void setModule(unsigned long,bool);

This should FIX #282 and be totally backward compatible.

Moreover there was a big delay in the red/write function. Using delayMicroseconds and the define SLOWMODE_DELAYUS is now set to the lowest always working time (From 1ms to 0.2ms).

All the performance data and some code explanation can be found in the link on top of my README.md file.

I only have a lm4f120h5qr and the sensors on a GY-80 so it may require to be tested on the other lm4f board.

@rei-vilo
Copy link
Member

To my surprise, Energia 12 supports fast I²C at 400 kHz (Fast-mode) as slave without any specific configuration.

400

The master was an Arduino board with a modified Wire library including #define TWI_FREQ 400000L instead of #define TWI_FREQ 100000L.

Like any other protocol, I²C standard is quite confusing as it features many sub-standards.

According to the official I²C-bus specification and user manual Rev. 6 — 4 April 2014, there are four modes:

  • Standard-mode: up to 100 kbit/s
  • Fast-mode: up to 400 kbit/s
  • Fast-mode Plus: up to 1 Mbit/s
  • High-speed mode: up to 3.4 Mbit/s

Chapter 16 Inter-Integrated Circuit (I2C) Interface of the Stellaris® LM4F120H5QR Microcontroller DATA SHEET now Tiva™ TM4C123GH6PM Microcontroller DATA SHEET says the MCUs support the four modes.

Are you also considering the four modes, including Fast-mode Plus and High-speed mode?

AxelTB added 2 commits April 28, 2014 23:26
Function setModule now uses I2C_SPEED_* enum for speed selection
@AxelTB
Copy link
Author

AxelTB commented Apr 28, 2014

I've never used IIC as slave, but is nice to know it can be easily used between two stellaris!

I didn't considered the other two fast mode but thanks to the documentation you linked me I have right now.

According to the Driver Library documentation of the function I2CMasterInitExpClk (http://www.ti.com/lit/ug/spmu298/spmu298.pdf [13.2.2.11]) neither of the two can be directly used with the driverlib.

Fast Mode Plus can be implemented simply by setting the right value in the I2CMTPR register. So I did it and tested with my usual GY-80 sensors.

High-Speed mode is not as simple. The datasheet states:

"The master is responsible for sending a master code byte in either Standard (100 Kbps) or Fast-mode (400 Kbps) before it begins transferring in High-speed mode"
([16.3.2.2])

I don't really need this kind of speed (And I don't know if my sensors supports it) but I'll look into it...

@rei-vilo
Copy link
Member

Yes, high speed mode is too different from the other modes and doesn't seem to be normalised. Let's forget about it.

Fast mode is very easy to implement —nothing to do in case of a slave— and fast mode plus shouldn't be that difficult.

@AxelTB
Copy link
Author

AxelTB commented Apr 28, 2014

Yeah, it didn't took very long.

I've tested it with my usual sensors but since you have a scope will be very useful to see the signal in the three master mode implemented.
Assuming your Arduino works fine in slave mode...

@rei-vilo
Copy link
Member

rei-vilo commented Jun 2, 2014

I'll give a try with both my logic analyser and my oscilloscope and let you know!

Can you please cross-check the I²C Clock Stretching Implementation for LM4F / TM4C #375?

Those two pull-requests are awaiting validation...

@rei-vilo
Copy link
Member

rei-vilo commented Jun 2, 2014

Hi!

Congratulations! Everything works as expected.

Configuration

  • Both master and slave are LaunchPad LM4F or TM4C.
  • Pull-up resistors of 10 kΩ

Here are the top speeds...

capture 2014-06-02 a 15 47 51

... and the details provided by my logic analyser

capture 2014-06-02 a 15 48 25
capture 2014-06-02 a 15 40 23
capture 2014-06-02 a 15 41 51

Next step: combine it with the clock stretching from #375!

@rei-vilo
Copy link
Member

rei-vilo commented Jun 2, 2014

Combining your modified Wire library with the two clock-stretching #375 related functions pause() and resume() doesn't seem to work.

Configuration

  • Both master and slave are LaunchPad LM4F or TM4C.
  • Pull-up resistors of 10 kΩ.
  • No problem if master is an Arduino board interfaced with a logic level converter.

@AxelTB
Copy link
Author

AxelTB commented Jun 2, 2014

Hi,
I'm glad all the test went fine!

I've never used the clock stretch but at a first glance it might be missing

ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, fastMode);

in the end of the resume() function. Obviously I'm far from sure since all the documentation I've found is about using I2CMasterTimeoutSet.

I hope this may help.

@rei-vilo
Copy link
Member

rei-vilo commented Jun 5, 2014

The ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, fastMode); is for the master device only. What about slave device?

Unfortunately, it doesn't seems to work. Maybe the 10kΩ are two high, and 4.7kΩ would suit better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow I²C 400-kHz Fast-mode (Fm)
2 participants