Wierd Mega1280 fault

Has anyone come across this one before:

If I write something to D33, it appears on both D33 and D34. If I write to D34, nothing happens.

I have checked with a multimeter and the pins aren't shorted out, and D33 connects to pin57, while D34 connects to pin58 as I would expect.
And yet... ?

Here is the test code I used:

int led = 33;
int led2 = 34;

void setup() {                
  pinMode(led, OUTPUT);     
  pinMode(led2, OUTPUT);     
}

void loop() {
  digitalWrite(led, HIGH);  
  digitalWrite(led2, HIGH);  
  delayMicroseconds(100);    
  digitalWrite(led, LOW);    
  delayMicroseconds(100);               
  digitalWrite(led, HIGH);   
  digitalWrite(led2, LOW);    
  delayMicroseconds(100);               
  digitalWrite(led, LOW);    
  delayMicroseconds(100);              
}

Basically 33 and 34 should oscillate at at different rates, but when viewed on a logic analyser they both oscillate at the same rate.
If I change:
led2=34
to:
led2=35

then 33 and 34 oscillate at the same rate, whilst 35 oscillates at half the rate.

If I then change it to be:
led = 34
led2 = 35,

then neither 33 nor 34 oscillate, but 35 oscillates at the rate it did before.

Any ideas? Or is my atmega1280 chip broken.

Which version of the IDE are you using? On my Mega2560 it appears to work correctly, the way you describe it should.

Can you do a verbose output, find the .elf file, and then do this ...

avr-objdump -S xxxx.elf > myoutput.txt

Then post the output file here as an attachment.

Its the latest IDE (1.0.1), with an Arduino Mega 1280.

I have attached the assembler.

I have had a look at the pins_arduino.h file and it appears in order.

assembler.txt (30.6 KB)

Can you run this sketch please and post what you get:

int led = 33;
int led2 = 34;

void setup()
{                
  Serial.begin (115200);
    
  Serial.println ("led");
  Serial.println (digitalPinToPort (led), HEX);
  Serial.println (digitalPinToBitMask (led), HEX);
  Serial.println (digitalPinToTimer (led), HEX);
  Serial.println ((int) portOutputRegister (digitalPinToPort (led)), HEX);
  
  Serial.println ("led2");
  Serial.println (digitalPinToPort (led2), HEX);
  Serial.println (digitalPinToBitMask (led2), HEX);
  Serial.println (digitalPinToTimer (led2), HEX);
  Serial.println ((int) portOutputRegister (digitalPinToPort (led2)), HEX);   
}

void loop() { }

I got:

led
3
10
0
28
led2
3
8
0
28
led
3
10
0
28
led2
3
8
0
28

Just as with yours.

Sounds like you might have a dodgy chip.

Yeah, thats what I was thinking. I will have to get a new atmega1280 chip and attempt to replace the chip. Actually I might get a 2560 as they are pin compatible, I might aswell get more flash space while I'm at it!

On second thoughts, i'll just get a new board. Its going to be too much of a pain trying to solder with the connectors in the way. Plus apart from that 1 pin, the board works fine. So if I get a whole new one, I'll have two :smiley: I think I might put a bit of super glue down the hole for D34 so I know not to use it...