Go Down

Topic: Wierd Mega1280 fault (Read 1 time) previous topic - next topic

Tom Carpenter

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:
Code: [Select]
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.
~Tom~

nickgammon

Which version of the IDE are you using? On my Mega2560 it appears to work correctly, the way you describe it should.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

nickgammon

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

Code: [Select]
avr-objdump -S xxxx.elf > myoutput.txt

Then post the output file here as an attachment.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Tom Carpenter

#3
Jun 28, 2012, 12:11 am Last Edit: Jun 28, 2012, 12:18 am by TCWORLD Reason: 1
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.
~Tom~

nickgammon

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

Code: [Select]
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:

Code: [Select]
led
3
10
0
28
led2
3
8
0
28
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Tom Carpenter

Code: [Select]
led
3
10
0
28
led2
3
8
0
28

Just as with yours.
~Tom~

nickgammon

Sounds like you might have a dodgy chip.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Tom Carpenter

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!
~Tom~

Tom Carpenter

#8
Jun 28, 2012, 08:48 am Last Edit: Jun 28, 2012, 08:50 am by TCWORLD Reason: 1
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 :D I think I might put a bit of super glue down the hole for D34 so I know not to use it...
~Tom~

Go Up