Wire library and ATmega8

I have an Arduino Duemilanove with ATmega328P, and the Wire library seems to be working fine. I am using it with the DS1307 library to read the time (see code below). If I remove the ATmega328P and insert an ATmega8-16P, then the Wire library no longer seems to work. I don’t see any read activity with a logic probe on the DS1307 pins. Are there any caveats to using the Wire library with the ATmega8? I can’t see any notable differences between the processors in the data sheets aside from memory. To answer any anticipated questions, yes I did program the correct bootloader and set the proper fuses, yes I did specify ATmega8 in the board setup, and yes I can upload and run other sketches that do not use the Wire library.

Any ideas? Thanks.

#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h>    // written by  mattt on the Arduino forum and modified by D. Sjunnesson
#include <Sure0832.h>

byte csPin = 7;
byte rdPin = 0;
byte wrPin = 6;
byte dataPin = 5;
byte numDisplays = 1;

boolean am;

int num, tens, ones;

Sure0832 LEDmatrix(csPin, rdPin, wrPin, dataPin, numDisplays);

void setup()
{

   Wire.begin();

}

void loop()
{

   LEDmatrix.setCursorPos(0);

   num = RTC.get(DS1307_HR,true);    //read the hour and also update all the values by pushing in true

   if (num > 11)
      am = false;
   else
      am = true;

   if (num > 12)
      num = num - 12;
   
   if (num / 10 == 1)
   {
      LEDmatrix.writeCol(0,0x41);   //manually write a "1"
      LEDmatrix.writeCol(1,0xFF);
      LEDmatrix.writeCol(2,0x01);
   }
   else
   {
      LEDmatrix.writeCol(0,0);   //clear
      LEDmatrix.writeCol(1,0);
      LEDmatrix.writeCol(2,0);     
   }
   
   LEDmatrix.setCursorPos(5);      
   LEDmatrix.writeChar(48 + (num % 10));

   LEDmatrix.writeCol(12,0x66);      // write a ":"

   LEDmatrix.setCursorPos(15);
   
   num = RTC.get(DS1307_MIN,false);  //read minutes without update (false)

   LEDmatrix.writeChar(48 + (num / 10));
   LEDmatrix.writeChar(48 + (num % 10));
   
   LEDmatrix.setCursorPos(28);
   
   if (am)
      LEDmatrix.writeAM();
   else
      LEDmatrix.writePM();
      
   delay(1000);

}

This could be RAM related.

The Wire library allocates 5 buffers of 32 bytes each = 160bytes.

You could try lower the numbers in both the Wire library and the twi.h files.

That's it! The Wire library by itself wasn't exceeding RAM, but when I add my font tables (declared as integer variables), it was too much for the little ATmega8. Thanks for your reply.

Do you have enough PROGMEM left over to put your font tables in? I drive a Sure0832 board that way, by storing an 8x8 font "row-wise" in subsequent bytes, and just use an 8 byte buffer to read the desired character into before sending it.