0

Problem:

ATMega328 Refuses to digitalWrite() to any pins, I can upload and run sketches using the board UNO from the ide on the 328 and can confirm it is working using the serial monitor (see code).

I am using this FTDI module.

Board Manager -- UNO works, but ATMega328 Doesn't

Tools Menu

By using the UNO board under board manager, I am capable of writing sketches and communicating with the 328 just fine. But when I use the ATMega328 at 5.5V,16Mhz I receive the following error.

         Using Port                    : COM3

         Using Programmer              : arduino

         Overriding Baud Rate          : 57600

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00



avrdude done.  Thank you.

Code & Serial Monitor "Proving" it works

I have tried every usable PWM and other pins to attempt to output using LED's, buzzers and even other Arduino's to read inputs but none of the pins will output high when requested.

I believe that Arduino IDE is attempting to compile my code for the UNO and those pins do not work on the ATMega328 but this could be completely incorrect and someone please correct me if this is a wrong assumption.

Lastly, I have been able to use the SCL and SCA pins to communicate with an I2C LED shield.

Does anyone know why I cannot write sketch to the ATMega328 using the FTDI and my configuration. Posted Below are images and very rough Fritzing schematics of how I am setup.

void setup() {
  Serial.begin(9600);
  pinMode(5,OUTPUT);
}

void loop() {
  Serial.println("TICK");
  digitalWrite(5,HIGH);
  delay(1000);
  digitalWrite(5,LOW);
  }

serial monitor

My Breadboard

ATMega328

Fritzing Schematic

Fritzing Schematic

7
  • 1
    the top bus of your breadboard is not powered ... why do you say that you can upload a sketch and then present an error listing that shows an upload failure?
    – jsotola
    Sep 28, 2020 at 5:47
  • pin 5 is low only a few milliseconds
    – jsotola
    Sep 28, 2020 at 5:49
  • 1
    The top part of my breadboard IS powered, I have two cables to the right, as shown in the second fritzing but just out of frame on the camera. If you read the text in the question I explain "By using the UNO board under board manager, I am capable of writing sketches and communicating with the 328 just fine. But when I use the ATMega328 at 5.5V,16Mhz I receive the following error." Sep 28, 2020 at 6:34
  • 1
    @StarCat imgur.com/8GR4GOs this is a link to what settings I am talking about, Arduino IDE gives you the option to select what chip, frequency and voltage your board is operating at. Using these settings I have been unable to write sketches to my board. The bootloader is a PU, I have not attempted to reflash the bootloader on my chip. Sep 28, 2020 at 16:44
  • 1
    You've selected the Arduino Pro in Board Manager and the "AVRISP MkII" programmer. You can't simply choose a different board manager and programmer and expect to keep using the same bootloader you've used for an Arduino Uno (although they have the same processor). You need to program the Arduino Pro bootloader into your ATMega328 or just keep using the Arduino Uno from Board Manager and the ArduinoISP programmer. Please add the image you linked to, to your question.
    – StarCat
    Sep 28, 2020 at 17:05

3 Answers 3

1

This may not be your only problem, but you need a second delay.

void loop() {
  Serial.println("TICK");
  digitalWrite(5,HIGH);
  delay(1000);
  digitalWrite(5,LOW);
  delay(1000);    // LOW for a second as well
  }

Otherwise you will not be able to see the LOW part, because it will be really quick.


I believe that Arduino IDE is attempting to compile my code for the UNO and those pins do not work on the ATMega328

The Uno has an Atmega328 on it, and I usually compile for the Uno when uploading to a custom board, so this is not the issue.

0

In combination with Nick Gammon's answer above, I was not aware that the physical pin numbers are different from the digital pin numbers used in the sketch. I resolved my issue by referring to this digital pin map.

Digital Pin Map

0

How old is your chip, or the bootloader on it? Most chips sold (with bootloaders preloaded) - and bootloaders available to upload - for the last several years at least, have uploaded at 115200 baud.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.