[Solved] Newbie question digitalWrite to MEGA pins 10-13

I am having difficulty writing to D10 to D13 on a MEGA. I can write to pins D7-D9 and D13-D15, but not pins D10-D13 using the following code.

pinMode(7, OUTPUT); // OK
digitalWrite(7, HIGH);

pinMode(8, OUTPUT); // OK
digitalWrite(8, HIGH);

pinMode(9, OUTPUT); // OK
digitalWrite(9, HIGH);

pinMode(10, OUTPUT); // Fail
digitalWrite(10, HIGH);

pinMode(11, OUTPUT); // Fail
digitalWrite(11, HIGH);

pinMode(12, OUTPUT); // Fail
digitalWrite(12, HIGH);

pinMode(13, OUTPUT); // Fail
digitalWrite(13, HIGH);

pinMode(14, OUTPUT); // OK
digitalWrite(14, HIGH);

pinMode(15, OUTPUT); // OK
digitalWrite(15, HIGH);

pinMode(16, OUTPUT); // OK
digitalWrite(16, HIGH);

I have tried using the noInterrupts() statement, but that does not solve my problem.

I know that I am doing something dump. Any suggestions?

Hoyt

The problem is obviously in the part of the code you don't show. Show the whole code if you want to get to the bottom of it.

This is the entire program.

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

pinMode(7, OUTPUT); // OK
digitalWrite(7, HIGH);

pinMode(8, OUTPUT); // OK
digitalWrite(8, HIGH);

pinMode(9, OUTPUT); // OK
digitalWrite(9, HIGH);

pinMode(10, OUTPUT); // Fail
digitalWrite(10, HIGH);

pinMode(11, OUTPUT); // Fail
digitalWrite(11, HIGH);

pinMode(12, OUTPUT); // Fail
digitalWrite(12, HIGH);

pinMode(13, OUTPUT); // Fail
digitalWrite(13, HIGH);

pinMode(14, OUTPUT); // OK
digitalWrite(14, HIGH);

pinMode(15, OUTPUT); // OK
digitalWrite(15, HIGH);

pinMode(16, OUTPUT); // OK
digitalWrite(16, HIGH);

//analogWrite(10, 250);

}

How are you checking that the pins go high or low? What is connected to them.

Why didn't you read the "How to Use This Forum" post and learn how to post code properly before you started? Did you think you were too special and didn't need the instructions?

I am connecting the MEGA to a Tektronix scope.

I have tried the above program on 3 different MEGAs. All behave similarly. I can output digital signals (and when using analogWrite() PWM signals) on D7-D9 and D14-D15, but not pins D10-D13.

It seems that D10-D13 are not accessible. I know that those pins can be used for interrupts, that is why I tried using the noInterrupts() statement.

I do not have a shield installed. The only other connection to the board is USB.

I have now read the "How to Use This Forum" post. Thank you for pointing it out.

Hoyt

There's nothing special about those pins that should cause you not to be able to use them. There is either something included in your code that you're not showing or there is something wrong with your board.

Delta,

Thank you for the feedback. The three MEGAs that I have been using are from the same batch. I do not recall having this issue with prior MEGAs. I will discuss with the manufacturer.

Regarding the code, I the COMPLETE program was posted above (all though as you noted without code markers). My actual program is many hundreds of lines long. However, the above test code is complete.

Again, thank you for your comments.

Hoyt

I've never used a Mega, but afaik it (like a Uno) has an LED on pin 13, one of your errant pins. So what happens if you run Blink?

Manor,

You suggestion confirmed that I have a board problem. Blink toggles the LED. When I connect my scope probe to the LED, the scope shows the transitions. However, when I connect my probe to pin 13, no signal is present.

Very good suggestion to use Blink.

Hoyt

Perhaps if you look at the schematics (available here) you'll see if there's something common to the connections on those duff pins that you could repair on the board with a bridge or something.

I wonder if those are genuine Megas?

Blink toggles the LED. When I connect my scope probe to the LED, the scope shows the transitions. However, when I connect my probe to pin 13, no signal is present.

The last part of that is inconsistent with the first part. If pin 13 does not change state then the LED would not light.

UKHeliBob:
The last part of that is inconsistent with the first part. If pin 13 does not change state then the LED would not light.

That was my first take on that comment too, but then I thought it may be possible that the connection is good as far as the led from the processor, but not good from there or the processor to the pin. Pin 13's source pin (for want of a better word) on the processor may be working, but there's no connection to pin 13 itself (ie the hole in the header where you jam wire in), while still having a connection to the led.

Are you connecting to the 6-pin ISP header, rather than the board-edge D10..13? On an Uno, those share a connection to the same AVR pins. But not an a MEGA.

It wouldn't be the first time a board suffered from bad solder connections. Check the solder pad to pin joints on D10-D13. Maybe use your scope to check the pads on the under side of your boards.

It would be a bit unusual to get a batch with the same solder joint problem. Just a thought...

SurferTim:
Maybe use your **micro-**scope to check the pads on the under side of your boards.

It would be a bit unusual to get a batch with the same solder joint problem.

Which gives credence to westfw's idea. Or, if the boards are clones, there could be a design flaw in the circuit?

I am just suggesting to check the repairable option first. If it is bad or cold solder joints, the OP can repair that. If the circuit boards have broken traces, that is not repairable.

@hoytf

I have tried the above program on 3 different MEGAs

Would you mind posting a pic of the MEGAs you are having problems with so we could check ours as well?
Thank you

Ok so I'm seeing "solved" at the top but no word from OP as what the solve is.... let's hope he updates.

I just ordered 10 MEGAs. I hope he has an isolated problem

The MEGA that I am using contains a jumper that allows the MEGA to use (a) shields designed for the Mega or (b) shields designed for the UNO/Ruggeduino. If the jumper is set for MEGA shields, D10-D13 operate properly. On the other hand, if the jumper is set for UNO shields, D10-D13 are used for other functions.

All I had do do to solve my problem was to move the jumper.

Hoyt