12
\$\begingroup\$

I'm configuring I2C on a PIC18 using the built-in functions of the C18 compiler as described in section 2.4 of the documentation:

void OpenI2C2( unsigned char sync_mode,
    unsigned char slew );

I'm not sure what I should do with slew. I can choose from two options, defined in i2c.h:

  • SLEW_OFF: Slew rate disabled for 100 kHz mode
  • SLEW_ON: Slew rate enabled for 400 kHz mode

In the datasheet in register 15-1, page 257, the two options are explained in a bit more detail:

  • 1 = Slew rate control disabled for standard speed mode (100 kHz and 1 MHz)
  • 0 = Slew rate control enabled for high speed mode (400 kHz)

I don't understand it though - I have a couple of questions:

  1. What is slew rate?

  2. For me, the two options don't make sense - what if I'd want to disable the slew rate for 400kHz and enable it for 100kHz? Why is this?

  3. When should I choose SLEW_OFF and when SLEW_ON?

\$\endgroup\$

1 Answer 1

9
\$\begingroup\$

Slew rate is how fast the signal changes from low to high, or vice versa. By limiting this abrupt transition, you can reduce ringing from signal reflections, and limit crosstalk between signal lines.

The way it works out, though, is that at 100kHz, the signal rates are so slow that the slew rate doesn't really matter; at 400kHz you may be able to fix an otherwise problematic circuit by limiting it; but then when you get to 1MHz you really need all the transition speed you can get, and so you just have to do good signal matching and route your lines more carefully.

The bit in question does nothing more than enable or disable the feature. The rest is simply advice. The speeds are in parentheses, as it is just a suggestion.

\$\endgroup\$
6
  • \$\begingroup\$ Thanks! It seems to be a nice option - why wouldn't I use slew rate control? \$\endgroup\$
    – user17592
    Commented Apr 13, 2013 at 17:16
  • 2
    \$\begingroup\$ @CamilStaps - My my understanding, it sounds like you might have misread the answer. Having sharp transitions (SLEW_ON) causes extra EMI noise and ringing. Having slow transitions (SLEW_OFF) reduces EMI but reduces the maximum useable frequency of the link. It's a trade-off. \$\endgroup\$
    – Tim
    Commented Apr 13, 2013 at 17:58
  • 1
    \$\begingroup\$ @gbarry: Ah, so with slew rate control off the signal is as close to square waves as the uC can make it. With slew rate control on the wave high/low transitions are more sloped (= less vertical) than they otherwise would be? \$\endgroup\$ Commented Apr 13, 2013 at 19:09
  • 1
    \$\begingroup\$ That's correct, although I'm not sure how dramatic it is on the PIC (I should check it). Historical note: The RS232 spec had a slew rate limitation, so someone came out with a driver chip that had nice slope-y output signals. And then we all started using faster and faster bps rates so we couldn't use that chip... \$\endgroup\$
    – gbarry
    Commented Apr 14, 2013 at 7:15
  • 2
    \$\begingroup\$ Three years later, and i had this same question, but I actually measured it. For future reference, on a PIC16F1454 with 4.7k pull-ups and a single slave on the bus, the fall-time is 2.9 ns without slew rate limiting (possibly limited by my 150 MHz probe), and 151 ns with slew rate limiting. It does not affect the rise-time. \$\endgroup\$
    – pipe
    Commented Sep 5, 2016 at 17:27