How to find the oscillator frequency in a wire library program?? 100 or 400KHz

HI,
I am interfacing PIC24 with Arduino UNO through I2C, my PIC is programmed with the oscillator frequency of 400KHz its visible and can be changed any time, but how can I find the interfacing frequency of arduino??

How to find the Oscillator frequency for Slave_receive code taken from FILE>EXAMPLES>WIRE>SLAVE_RECEIVE

#include <Wire.h>

void setup()
{
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}

void loop()
{
delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}

but how can I find the interfacing frequency of arduino??

What does the oscillator frequency have to do with anything?

I guess they should be in same frequency for I2C communication right

Im not sure but I would guess that the pic does it in software while the arduino has actual hardware to take care of that, perhaps you need to dig through the 328 datasheet to find that

Perhaps this in the arduino source can help you

 void twi_init(void)
{
  // initialize state
  twi_state = TWI_READY;
  
  // activate internal pullups for twi.
  digitalWrite(SDA, 1);
  digitalWrite(SCL, 1);

  // initialize twi prescaler and bit rate
  cbi(TWSR, TWPS0);
  cbi(TWSR, TWPS1);
  TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;

  /* twi bit rate formula from atmega128 manual pg 204
  SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
  note: TWBR should be 10 or higher for master mode
  It is 72 for a 16mhz Wiring board with 100kHz TWI */

  // enable twi module, acks, and twi interrupt
  TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
}

If you look I side the wire.c file you will find the I2C frequency defined at the start of the file. This is 100KHz but you can change it here if you want.

Hi Grumpy Mike,
Can I know how to find wire.c file in Arduino...coze I am new to this topic

It looks like they have changed it on the latest distribution
This is an old post from the forum
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291567011
which shows it was valid at one time.
While the Wrie.cpp file is still there but I can't find that line at the start that used to define it.

Can I know how to find wire.c file in Arduino.

Mac or PC?
I only know where it is on a Mac. It is inside the arduino application, left click it and choose show package contents. Then navigate:-
Contents/Resources/Jave/libraries/Wire/Wire.cpp

Anyway you are probably better off getting this library as it is more flexible than the standard one, it will allow you to simply change the speed and optionally enable the pull ups.

By the way always use external pull up resistors the internal ones are too big to work correctly.
See:-