seperate ATmega 2560 - turn on a single LED - troubleshooting I have got my own PCB with "some stuff" on it and first I want to make it run a simple "turn on LED".

My setup:


Atmega 2560
LED connected to PE4 (D2 in Arduino language) => PE4 - LED - 1K resistor - 5V
ceramic resonator (CSTCE16M0V53-R0 16MHZ) connected to XTAL1 + XTAL2 with 1MOhm resistor inbetween
all VINs are pulled to GND with capacitors






Upload is working through ICSP (MISO, MOSI, SCK, RESET, 5V, GND) with an USBasp

Here is my Arduino sketch, which I upload through the Arduino software:

void setup() {
  pinMode(2, OUTPUT);
}

void loop() {
  digitalWrite(2, LOW);    
}


I checked the fuses on the atmega as well:

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (H:FD, E:D8, L:FF)


avrdude uploads successfully: (output truncated!)

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9801
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: writing flash (1518 bytes):
Writing | ################################################## | 100% 5.47s
avrdude: 1518 bytes of flash written
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 3.45s
avrdude: verifying ...
avrdude: 1518 bytes of flash verified

avrdude done.  Thank you.


Problem: the LED doesn't work. It is OFF all the time.

Any ideas why it is not working?

Cheers
Hendrik
You are saying that the LED lights if you write LOW to it.


  I need to pull the output pin to LOW to make the LED work 


That's exactly what you expect.



Since the other end of the LED is wired to +5 V, then you need to drive the pin low to have a voltage difference over the LED, and for it to light.




  I double checked the Atmega and it is a ATmega2560V, which is rated for 8Mhz. Any chance to fix this with the existing PCB? Change the Fuses to use the internal clock? 


Yes, I suggest you do that.

Look at Engbedded Atmel AVR® Fuse Calculator to see what to set them to. I suggest the internal 8 MHz oscillator.