Go Down

Topic: Toggling ATmega 2560 Unconnected Pins (Read 163 times) previous topic - next topic

dm41nes

Code: [Select]
void setup() {
  // put your setup code here, to run once:
//  int PE6;
//  int PE7;

  pinMode(PE6,OUTPUT);
  pinMode(PE7,OUTPUT);
  pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(PE6,HIGH);
  digitalWrite(PE7,HIGH);
  digitalWrite(LED_BUILTIN,HIGH);

  //DDRE = DDRE | B11111100;
  delay(500);
  digitalWrite(PE6,LOW);
  digitalWrite(PE7,LOW); 
  digitalWrite(LED_BUILTIN,LOW);
  delay(500);

  //DDRE = DDRE | B00000011; 

 
}


Is it possible to control PE6 and PE7 per Arduino IDE? My code didn't give any errors (both PE* and DDRE ways). I even have the built-in LED blinking every half second. I know that these two port pins are not physically connected to the Arduino Mega 2560 in the schematic.

Maybe I'm not controlling it correctly or even measuring the pin right with the multimeter?

dm41nes

Just checked with an oscilloscope, my LED is toggling at 2V, but nothing for PE6 and PE7. Am I initializing the ports wrong?

DrAzzy

pinMode(PE7,OUTPUT); doesn't work. You need to do everything manually (eg, setting the DDRE register).

Or use MCUDude/hansibull's MegaCore, which supports all pins  2560 and 2561 like normal arduino pins.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

dm41nes

 Nevermind! I got it on the scope :D

Code: [Select]
void setup() {
  DDRE = B11111111;

  pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
  digitalWrite(LED_BUILTIN,HIGH);
  PORTE = B11111111;
  delay(500); 
  digitalWrite(LED_BUILTIN,LOW);
  PORTE = B00000000;
  delay(500);
}

westfw

The constants like PE3 exist, but are not used by the arduino functions like PinMode().
It would be like saying pinMode(HIGH, FALSE)

Go Up