Pages: [1]   Go Down
Author Topic: I2C is different between MEGA and UNO?  (Read 977 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Open Source, open-minded!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been experience some I2C problems between MEGA and UNO. First I wire a I2C device#1 to MEGA, and works fine. Then I wire the device#1 to UNO and the same program, and it doesn't work.

A few days later, I did another experiment. I wire I2C device#2(which works with UNO each time) to MEGA, and it doesn't work with the same program.

Then I did a final test with I2C device#3, I work with MEGA at both 400kbps and 100kbps rate, but device#3 can only works with UNO at 100kbps rate.

Can anyone tell me the reason?
Logged

http://www.geekonfire.com
Open Source, open-minded!

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 499
Posts: 19065
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What program? What wiring? More details.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Open Source, open-minded!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What program? What wiring? More details.
One of the device is http://www.geekonfire.com/wiki/index.php?title=I2C_OLED_Panel(128x64)#Resources. It works on UNO and MEGA at 100kbps, but at 400kbps only works at MEGA.(I have tested it on MEGA2560,MEGA1280 and MEGA Olympic)

code in library:
    //uint8_t twbrbackup = TWBR;
    //TWBR = 12; // upgrade to 400KHz!
//    TWBR = twbrbackup;
if I enable the above sentences, It doesn't work at UNO.
Code:

void GOFi2cOLED::display(void) {
  sendCommand(0x00 | 0x0);  // low col = 0
  sendCommand(0x10 | 0x0);  // hi col = 0
  sendCommand(0x40 | 0x0); // line #0

    // save I2C bitrate
    //uint8_t twbrbackup = TWBR;
    //TWBR = 12; // upgrade to 400KHz!

    // I2C
    #if defined(ARDUINO) && ARDUINO >= 100
    for (uint16_t i=0; i<(128*64/8); i++)
    {
      // send a bunch of data in one xmission
      Wire.beginTransmission(SlaveAddress);
      Wire.write(GOFi2cOLED_Data_Mode);            // data mode
      for (uint8_t x=0; x<16; x++)
      {
        Wire.write(buffer[i]);
        i++;
      }
      i--;
      Wire.endTransmission();
    }      
    #else
    for (uint16_t i=0; i<(128*64/8); i++)
    {
      // send a bunch of data in one xmission
      Wire.beginTransmission(SlaveAddress);
      Wire.send(GOFi2cOLED_Data_Mode);            // data mode
      for (uint8_t x=0; x<16; x++)
      {
        Wire.send(buffer[i]);
        i++;
      }  
      i--;
      Wire.endTransmission();
    }
    #endif    
//    TWBR = twbrbackup;
}
« Last Edit: September 05, 2012, 04:15:20 am by jimbo.we » Logged

http://www.geekonfire.com
Open Source, open-minded!

Detroit, MI
Offline Offline
Full Member
***
Karma: 0
Posts: 117
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is confusion when you say "enable all above sentences". Please post the specific code which works on the atmega2560 but not the Uno. (code that I can copy and paste into an IDE, without having to physically take out specific comments you have).
« Last Edit: September 04, 2012, 02:50:11 pm by johnnyonthespot » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 499
Posts: 19065
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Open Source, open-minded!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have anyone had any idea?
Logged

http://www.geekonfire.com
Open Source, open-minded!

Pages: [1]   Go Up
Jump to: