Mega pins 20,21, SDA/SCL question

I was rerunning a test program i have for digitalWriteFast tonight. The basic idea is to test that all of the commands work correctly by connecting arduino pins with resistors and checking to be sure they can read and write to each other.

Back when I first wrote it I found that the resistor i chose elsewhere didn't work for pin 13, googled that and found a place where RetroLefty had discussed that. It relates to the LED and resistor built into the board for pin 13.

Tonight I was using 10K ohm resistors almost everywhere else. I kept getting errors on the Mega 1280 on some of the commands on pin 20 and 21 until I reduced the resistor there to 330 ohms. Those pins are D0 and D1, SCA, SCL. Here's the code from the test

pinModeFast(20,INPUT);
digitalWriteFast(20,HIGH); 
pinModeFast(21,OUTPUT);
digitalWriteFast(21,LOW);
delay(1);
if((int) digitalReadFast(20) != LOW) error(20,21,1);  //failed w 10K ohm

pinModeFast2(20,INPUT);
digitalWriteFast2(20,HIGH);
pinModeFast2(21,OUTPUT);
digitalWriteFast2(21,LOW);
delay(1);
if((int) digitalReadFast2(20) != LOW) error(20,21,12);  //failed w 10K ohm

pinModeFast(21,INPUT);
digitalWriteFast(21,HIGH); 
pinModeFast(20,OUTPUT);
digitalWriteFast(20,LOW);
delay(1);
if((int) digitalReadFast(21) != LOW) error(21,20,2);  //failed w 10K ohm

pinModeFast2(21,INPUT);
digitalWriteFast2(21,HIGH);
pinModeFast2(20,OUTPUT);
digitalWriteFast2(20,LOW);
delay(1);
if((int) digitalReadFast2(21) != LOW) error(21,20,21);  //failed w 10K ohm

pinModeFast(21,INPUT);
digitalWriteFast(21,LOW); 
pinModeFast(20,OUTPUT);
digitalWriteFast(20,HIGH);
delay(1);
if((int) digitalReadFast(21) != HIGH) error(21,20,3);   //suceeded

pinModeFast2(21,INPUT);
digitalWriteFast2(21,LOW);
pinModeFast2(20,OUTPUT);
digitalWriteFast2(20,HIGH);
delay(1);
if((int) digitalReadFast2(21) != HIGH) error(21,20,3);   //suceeded

pinModeFast(20,INPUT);
digitalWriteFast(20,LOW); 
pinModeFast(21,OUTPUT);
digitalWriteFast(21,HIGH);
delay(1);
if((int) digitalReadFast(20) != HIGH) error(20,21,4);   //suceeded

pinModeFast2(20,INPUT);
digitalWriteFast2(20,LOW);
pinModeFast2(21,OUTPUT);
digitalWriteFast2(21,HIGH);
delay(1);
if((int) digitalReadFast2(20) != HIGH) error(20,21,4); //suceeded

I imagine I happened to pick a small resistor the last time I did this on these pins. What would be special about pins 20 and 21??

You identified it yourself: those pins are SDA,SCL the I2C (a.k.a. TWI pins). There are already 10k resistors on those pins from 5V to the pin (see the Mega schematic).

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Thanks. Even this morning when I first looked at the schematic I just saw a straight line from the 1280 chip to pins 20 and 21. It took me a while to find the detail in the upper right corner.

That certainly explains it and also lets me understand that using I2C AKA TWI is a tad easier than I had previously realized. I had read that the internal pullup MIGHT be enough to let you get by without an external resistor, but had never realized that an external pullup is conveniently built into the Mega board(s).