|
|
View previous topic :: View next topic |
Author |
Message |
sseidman
Joined: 14 Mar 2005 Posts: 159
|
High-speed i2c example |
Posted: Tue Jul 17, 2012 4:25 pm |
|
|
http://www.i2c-bus.org/highspeed/
Does anyone have any example code for high-speed i2c by putting out the "8-bit master code" at 400kHz? Do I need a second slow master to kick the first master into high gear?
I'm trying specifically to use the MCP4728 at high speeds, and the data sheet section 5.1.1 talks about this, but never shows a sequence. Reading the high speed doc from i2c-bus.org is just confusing me, and I can't find any app notes or examples.
thanks! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Jul 17, 2012 4:38 pm |
|
|
CCS does allow 'fast' mode and you can set the speed with the use I2C(...) directive.
Pressing F11 while your project is open, does allow the onscreen help files to appear.Just locate the preprocessor directives and then I2C.There are several pages of help as well as actual code examples.
These might shed light on what you're asking about.
hth
jay
+++++++++++++++++++++++++
Temtronic,
Please read OP's post before replying.
His query is "High Speed" (3.4 MHz) mode not Fast mode.
Do not advise F11 on advanced topics !!
The quickest draw does not always win the prize.
- Forum Moderator
+++++++++++++++++++++++++
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Jul 18, 2012 2:17 am |
|
|
Big question, _what PIC_. Few PIC's support the high speed mode (not sure any do - I don't know of any!). You need active pull up on the I2C lines, and a chip that generates the asymmetric clock used by this. Most PIC's only support rates up to 1Mbps on I2C, and symmetric clocks. Have only played with it on other chips than the PIC. There may be some new DSP PIC that does support it, but if so we need to know what chip?.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Jul 18, 2012 4:35 am |
|
|
oops...guess I need better bifocals !Sorry about that....since we are a 'worldwide' forum,differnet words can mean the same thing..
If we wait a week or two 'ultra' speed will be out and that will obsolete slow,fast and the 'new' high speeds....
I'm still upset that 'legacy' devices are all gone off PCs.
sigh ,I'm getting too old for this stuff. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Jul 18, 2012 4:53 am |
|
|
Yes. It is also made worse, since you have historical references to 'Fast' I2C, as 'high speed', quite a bit of generic stuff that uses I2C a little 'faster' than this, talking about this as 'high speed' (which the PIC can do in most cases, _provided_ you turn off any slew rate limiting), and then you have the 'HS' high speed.
Aaargh......
Problem with the PC, is it is so driven by price. Features that were superior or useful, have been priced out of existence, and replaced with remarkably cheap kit, which (unfortunately), while offering 'paper' performance that is great, performs poorly when actually used. :(
Best Wishes |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Wed Jul 18, 2012 6:20 am |
|
|
Thanks for the answers-- sorry I wasn't more specific, temtronic.
The answer to which PIC is whichever PIC I need to use! It looks like for different reasons I need to take a jump up to the dspic33's, but it does need to be a DSP.
I'd love to get to at least 3x faster than the 400kHz spec-- I don't think 3.4 MHz will be achievable without some extreme measures, but if I can hit 1.2MHz, I think that might give me enough headroom.
So, it sound like I can try to use plain old FAST i2c, and use FAST=1200000, disabling slew rate limitations, and using an active pullup/accelerator like the LTC1694?
Thanks for the leads! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Jul 18, 2012 6:34 am |
|
|
dum question from the old guy..but .. is there perhaps an SPI version of this type of device(quad 12bit DAC) that might work for you or are you commited to using this part?
as for the speed , I'd test using the I2C fast option,say 400KHz, then up the speed a bit until it either fails or some other error(maybe the compiler won't accept 1,000,000 as a speed ?) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Jul 18, 2012 8:00 am |
|
|
Not quite as simple as that.
The key with genuine 'HS' parts, is you send them a command using normal 'fast' mode I2C, to 'turn up' to the HS mode. Then they should turn on the active termination, and start accepting HS signalling. When the transfer is complete, they automatically switch back 'down'. Key difference with HS, is that the clock waveform has 2:1 asymmetric timing. How important this is for the particular chip concerned here, I don't know, but on my previous 'playing' with this, I could not get HS to work, until this criterion was met....
I was lucky, using a FPGA, so just generated the waveforms needed. I was actually sending from a PIC, but the 'PIC' involved was a 'virtual' one in the same FPGA. Also remember the termination resistors need to be _low_ at the higher speed. I used 470R.
Seriously, the first thing to do, is talk to Microchip. Ask _them_ if they have examples for using this chip with a PIC, and the fastest speeds it can support with this. It may well turn out that they say '1MHz is max with a PIC', or that they can give you a working example, and say 'you can go to 2MHz, with this particular DSPIC' (my memory is that it ought to be possible to get to this with certain clocks).
I don't think there is any real problem (except possibly having to update SPBRG manually), with the speed switch on the PIC, but just how fast you can get, and whether the chip will accept the output from most PIC's is open to question..... |
|
|
sseidman
Joined: 14 Mar 2005 Posts: 159
|
|
Posted: Fri Jul 27, 2012 2:32 pm |
|
|
Thanks for all the suggestions. I managed to sidestep the issue using a 32-sample buffer on the accelerometer I'm using. I now have more than enough clock ticks to accomplish processing between FIFO flushes by clocking at 1MHz. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|