View previous topic :: View next topic |
Author |
Message |
dima2882
Joined: 13 Jul 2005 Posts: 25 Location: Maryland
|
Highest speed possible with software I2C? |
Posted: Mon Apr 03, 2006 12:44 pm |
|
|
Hello all,
I am stuck having to use SPI and I2C on the same PIC18F458 device. Based on info from previous postings, I am using 10MHz SPI using the dedicated hardware lines, and will use I2C on some other two I/O lines , not using the HW I2C module on this PIC. Does anyone know what kind of speed I could be looking at with the SW I2C? Could I meet the 400 kHz of the fast I2C spec?
Thanks,
Vadim |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Apr 03, 2006 12:52 pm |
|
|
No one can answer that question without knowing the clock speed of the micro! Why do you have to meet the 400KHz spec? You do realize that is the max rate and slower rates are okay. |
|
|
dima2882
Joined: 13 Jul 2005 Posts: 25 Location: Maryland
|
|
Posted: Tue Apr 04, 2006 9:14 am |
|
|
Sorry, I didn't put the clock of the PIC... its 40 MHz, thus allowing for the afore-mentioned 10 MHz SPI. I would really like to have a sampling rate of 200 kHz with the I2C sensor I'm using, so its higher than the standard 100 kHz spec. I figured I'd need to go to 400 kHz next. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Apr 04, 2006 11:05 am |
|
|
You can't sample a device at 200KHz if you communicate to it @ 400K BITS PER SECOND. Think about it. That would only allow 2 bits per sample. |
|
|
dima2882
Joined: 13 Jul 2005 Posts: 25 Location: Maryland
|
|
Posted: Tue Apr 04, 2006 11:43 am |
|
|
Of course not, I simply meant that the minimum the design would have needed is 200 kHz. It can go higher, but not lower, hence the full speed 400k I2C spec is the ticket. In any case, I got it on a breadboad working off two general I/O pins, and got the I2C packets at 400 kHz, so it does seem to work. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Apr 04, 2006 12:43 pm |
|
|
I think you miss Mark's point that you don't have to choose between 100kHz and 400kHz. Those numbers are limits, not exact speeds like an RS232 asynchronous serial link. If you want to use 200kHz go ahead, or 210kHz, or anything less than 400kHz. The master sets the speed and the slave just has to keep up with it. You can even stop in the middle of a byte, service a short interrupt, and continue the byte. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
dima2882
Joined: 13 Jul 2005 Posts: 25 Location: Maryland
|
|
Posted: Tue Apr 04, 2006 3:01 pm |
|
|
Ahh, I see now. Well that clears things up. Thanks for your help guys. |
|
|
|