atmega328p running at 8mhz with external xtal and serial communication

Hello, I've an atmega328p running at 8mhz with external xtal and I need serial communication, first I tried to burn the Arduino bootloader with:

avrdude -c usbtiny -p atmega328p -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m
avrdude -c usbtiny -p atmega328p usb -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex -U lock:w:0x0f:m

But after this I can not upload new programs using Arduino IDE

I also tried uploading blink programs by ISP and works well at correct frequency, I used the followind command:

avrdude -V -F -c usbtiny -p m328p usb -U flash:w:main.hex

The problems seems to be in the baud rate,I uploaded que following code:

void setup() {                
Serial.begin(9600);   
}

void loop() {
  Serial.println("hola mundo");
  delay(2000);
}

And I obtained trash on my serial console each 2 seconds.

It seems that the problem is in the baud rate, but I can not understand how to fix it.

Somebody can help me?

Best regards.

Try selecting "LilyPad Arduino w/ ATmega328" from the boards section under Tools of the IDE.

Then select "Burn Bootloader" from the Tools menu.(using programmer)

Then try loading your sketch (with board still set to "LilyPad Arduino w/ ATmega328" and using usb/serial cable; not programmer).

Have a look at the settings for this selected board in the arduino/hardware/arduino/boards.txt file.

Hello lemming, I burn the "LilyPad Arduino w/ ATmega328" bootloader using arduino IDE and tried to load my sketch using usb/serial cable (dfrobot ftdi) but it reply:

avrdude: stk500_getsync(): not in sync: resp=0x30

:(

Hi xload,

When you plug your dfrobot ftdi into your PC, does it show up as a com port under the Tools-> Serial Port in the IDE? If so, is it selected? (to avoid confusion, unplug the SPI programmer).

Also, it sounds like you have made up a custom board (maybe on a breadboard?). There may be a problem with the wiring. Have you got a circuit diagram or better still a photo of the board for us to check?

lemming: Hi xload,

When you plug your dfrobot ftdi into your PC, does it show up as a com port under the Tools-> Serial Port in the IDE? If so, is it selected?

Yes, it is show as /dev/ttyUSB0 and is selected ins the IDE

To check out the serial side of things, try programming the example sketch "ASCIItable" under File->Examples-> 4. Communication in the IDE into the 328 using the ISP.

Unplug the programmer and plug in the dfrobot and hook it up to the arduino. Open up the monitor and set the baud rate to 9600. Reboot the Arduino and see if the ASCII table shows up. It only runs once per boot so you have to have the monitor up and running when it boots or you will miss it.

How have you got the reset pin wired on the Arduino? Is it on a breadboard?

To check out the serial side of things, try programming the example sketch "ASCIItable" under File->Examples-> 4. Communication in the IDE into the 328 using the ISP.

Unplug the programmer and plug in the dfrobot and hook it up to the arduino. Open up the monitor and set the baud rate to 9600. Reboot the Arduino and see if the ASCII table shows up. It only runs once per boot so you have to have the monitor up and running when it boots or you will miss it.

I burn this example using the ISP and works well.

Now, I don't know why, i can burn the bootloader, upload once a program using the dfrobot FTDI (I tried uploading the ASCIItable example) but I can not upload more sketches with FTDI, arduino IDE give me the following error:

avrdude: stk500_recv(): programmer is not responding

How have you got the reset pin wired on the Arduino? Is it on a breadboard?

I'm using a custom circuit in a pcb board. the reset pin is wired to VCC through a resistor.

xload:

To check out the serial side of things, try programming the example sketch “ASCIItable” under File->Examples-> 4. Communication in the IDE into the 328 using the ISP.

Unplug the programmer and plug in the dfrobot and hook it up to the arduino. Open up the monitor and set the baud rate to 9600. Reboot the Arduino and see if the ASCII table shows up. It only runs once per boot so you have to have the monitor up and running when it boots or you will miss it.

I burn this example using the ISP and works well.

Now, I don’t know why, i can burn the bootloader, upload once a program using the dfrobot FTDI (I tried uploading the ASCIItable example) but I can not upload more sketches with FTDI, arduino IDE give me the following error:

avrdude: stk500_recv(): programmer is not responding

How have you got the reset pin wired on the Arduino? Is it on a breadboard?

I’m using a custom circuit in a pcb board. the reset pin is wired to VCC through a resistor.

No .1ufd cap wired in series between the reset pin and the DTR or RTS signal on the FTDI module? If not then the auto-reset the IDE issues just prior to the upload operation won’t force your board to run the bootloader code at the correct time. So either add the cap or add a reset switch to the reset pin and learn how to press and release the reset button at the correct moment the IDE requires it during an upload operation.

Lefty

Pipped at the post while I was sleeping!

Retrolefty is spot on as usual. I would run with the .1uF cap option rather than use a reset switch. With frequent updates during testing, I find it easier to just click the program button rather than get the timing right for the program button/reset switch combination.

Hello, a lot of thanks! with .1ufd cap wired in series between the reset pin and the ftdi DTR works well!!!!