very strange thing about UC3B internal pull ups for TWI

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

I just found out on my UC3B design without any device connecting to TWI bus yet, that after enabling the internal pull-ups of SCL and SDA pins and then if I enable the multiplexed TWI module pins, both pins read voltage close to 0V. But if I don't enable module pins and both GPIOs are by default input, then both pins measures 3.3V.

I also measured the resistance between 3.3V VDD and both SCL and SDA pins. when I haven't enable the multiplexed TWI module, both pins give about 8.5Kohm, which is a indication that the pull-up is enabled. but after i enabled the multiplexed TWI module, both pins give open circuit, so there is no pull-up any more. And I also tried to enable module first, then enable pull-ups, but still they are open circuit.

So how could function gpio_enable_module_pin() disable the pull-ups? All it did is:

  volatile avr32_gpio_port_t *gpio_port = &GPIO.port[pin >> 5];

  // Enable the correct function.
  switch (function)
  {
  case 0: // A function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
    break;

  case 1: // B function.
    gpio_port->pmr0s = 1 << (pin & 0x1F);
    gpio_port->pmr1c = 1 << (pin & 0x1F);
    break;

  case 2: // C function.
    gpio_port->pmr0c = 1 << (pin & 0x1F);
    gpio_port->pmr1s = 1 << (pin & 0x1F);
    break;

  default:
    return GPIO_INVALID_ARGUMENT;
  }

  // Disable GPIO control.
  gpio_port->gperc = 1 << (pin & 0x1F);

  return GPIO_SUCCESS;

this GPERC shouldn't have anything to do with PUER, right?

according to I2C standard, when TWI master is not enabled, both pins should be 3.3V, right?

So why I got about 0V if I enable the module pins???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should have external pullups on the TWI bus.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well, now i really wish i have that external pull-ups, but still why???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

now i have put two external 10K pull-ups and the TWI bus works.
But I still just want to use the internal Pull-ups...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The actual resistance required for TWI pullups depends on bus capacitance and operating frequency, something the internal pullups can't compensate for. For instance, 10K might be enough for 100Khz operation, but is very unlikely to be low enough for 400Khz operation.

We tried to run 400Khz with 4.7K pullups and the rise time was too long causing the UC3B to sometimes think it lost master arbitration when it was the only master.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, i think on my PCB design, the capacitance is quite low. anyway, i can try to run it at 400KHz with this external 10K resistor first. Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are probably wasting time with anything less than 2.2K, but have fun anyway. We found this document very useful when we were debugging TWI bus:

http://www.standardics.nxp.com/literature/presentations/i2c/pdf/debug.i2c.oscilloscope.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, but now with 10K my TWI works, I get correct reading all the time.