[solved] Code runs on attiny45 but doesnt on attiny25

hello,

I wrote a sketch to controll an LCD and it works pretty well with a (per tinytuner) calibrated attiny45 running at 1Mhz. I’m using this arduino tiny core: http://code.google.com/p/arduino-tiny/. The compiled code is smaller than 2k, so I thought its a good idea to save my t45 (maybe for an USB project) and use a attiny25 instead. I changed the settings and uploaded successfully.

BUT:

After uploading my sketch to the t25 it seems to initialize the LCD but nothing more. Nothing appears, nothing happens. Already checked if I might run out of SRAM but it doesnt seem so:

C:\>avr-size %temp%\build...\lcd_octopus.cpp.elf -C --mcu=attiny25
AVR Memory Usage
----------------
Device: attiny25

Program:    1932 bytes (94.3% Full)
(.text + .data + .bootloader)

Data:         92 bytes (71.9% Full)
(.data + .bss + .noinit)

More project details:
Its a little sketch to show a moving octopus on the LCD (like this: pcomp - LCD Octopus on Vimeo). Its supposed to be a gift :). The problem is the original code was for an LCD with UART (?) interface. I was trying to connect my LCD in 4-Bit mode (so 6 pins should be enough) directly to my t45 to use it with the generic LCD lib. But I couldnt, because the reset pin seems not to work as output (any advice?). So I used a PCF8574 with the TinyWireM lib. I had to rewrite the LCD routines because of my weird wiring (wanted to stay single layered). So… in the nutshell:

Sketch < 2k works @ t45; doesnt @ t25 :frowning:

Ill be grateful for any help!

lny

[EDIT]
Ok I stopped using the tinywire lib and implemented my own I2C write rountines like here: http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html. This turned out in the end:

#define SDA        PB0        // i2c Serial data
#define SCL        PB2        // i2c Serial clock
#define pcf_addr   0x40       // 00100000 slave address write

//------------------- library I2C --------------------------
void i2c_start() {
// |-[S]-|  ;Start Condition
  PORTB &= ~(1 << SDA);      // SDA=0
  delayMicroseconds(1);
  PORTB &= ~(1 << SCL);      // SCL=0
  delayMicroseconds(1);
}

void i2c_ack() {
// |-[A]-|  ;Active LOW 
  PORTB &= ~(1 << SDA);      // SDA=0
  delayMicroseconds(1);
  PORTB |= (1<<SCL);      // SCL=1
  delayMicroseconds(1);
  PORTB &= ~(1 << SCL);      // SCL=0
  delayMicroseconds(1);
  PORTB &= ~(1 << SDA);      // SDA=0
  delayMicroseconds(1);
}

void i2c_stop() {
  // |-[P]-|  ;Stop Condition
  PORTB |= (1<<SCL);      // SCL=1
  delayMicroseconds(1);
  PORTB |= (1<<SDA);      // SDA=1
}

void i2c_byte(byte data) {  // actually write a data byte
  byte iBit = 0;
  for(byte iloop = 0 ; iloop < 8 ; iloop++)
  {
    iBit = ((data & 0x80) >> 7 ) ; 
    delayMicroseconds(1);
	
    if (iBit) PORTB |= (1 << SDA);  // SDA=iBit
    else      PORTB &= ~(1 << SCL); // SDA=iBit
	
    delayMicroseconds(1);
    PORTB |= (1<<SCL);      // SCL=1
    delayMicroseconds(1);
    PORTB &= ~(1 << SCL);      // SCL=0
    delayMicroseconds(1);
    PORTB &= ~(1 << SDA);      // SDA=0
    data = data << 1 ;
  }
  delayMicroseconds(1);
}
//------------------- end library I2C -------------------------

Thx to everyone anyway.

Lny

lcd_octopus.ino (9.81 KB)

Sketch < 2k

that is irrelevant as its just how much space its going to take in flash, how much ram is it using? the 25 only has 128 bytes

Data:         92 bytes (71.9% Full)
(.data + .bss + .noinit)

Doesnt that mean SRAM usage? Once I saw another command which lists all variables which will be used, but I cant remember it. Maybe you know it?

milkpirate:

Data:         92 bytes (71.9% Full)
(.data + .bss + .noinit)

Doesnt that mean SRAM usage? Once I saw another command which lists all variables which will be used, but I cant remember it. Maybe you know it?

SRAM also has to store the return stack, local variables, etc. 36 bytes probably isn't enough for that.