-
Notifications
You must be signed in to change notification settings - Fork 670
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
base: master
Are you sure you want to change the base?
Conversation
To my surprise, Energia 12 supports fast I²C at 400 kHz (Fast-mode) as slave without any specific configuration. The master was an Arduino board with a modified Wire library including 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:
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? |
Function setModule now uses I2C_SPEED_* enum for speed selection
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:
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... |
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. |
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. |
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... |
Hi! Congratulations! Everything works as expected. Configuration
Here are the top speeds... ... and the details provided by my logic analyser Next step: combine it with the clock stretching from #375! |
Combining your modified Wire library with the two clock-stretching #375 related functions Configuration
|
Hi, I've never used the clock stretch but at a first glance it might be missing
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. |
The Unfortunately, it doesn't seems to work. Maybe the 10kΩ are two high, and 4.7kΩ would suit better. |
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.