trying to upload sketch Atmega328 8Mhz internal clock

Thread Starter

Luigi Santagada

Joined Jan 26, 2019
7
Hi,
I'm using an atmega328p in standalone mode with 8Mhz internal clock.
I can burn the bootloader and sketch thorugh the isp interface but i can't upload sketch with a usb-to-ttl (tx and rx).

On pin reset i use 100nF capacitor and 10k pullup resistor.
When i upload sketch the ide starts but never end.

Do you know if is there some reason becouse the UART doesn't work in this case?

Thanks.
 

LesJones

Joined Jan 8, 2017
2,317
The Arduino Uno uses a 16 Mhz crystal. As you are using an 8 Mhz crystal the baud rate of the serial port will be half that of the uno. So you will have to set the baud rate on the USB to serial converter to half the value you would expect to use.

Les.
 

Thread Starter

Luigi Santagada

Joined Jan 26, 2019
7
Hi,
Thanks,It's just that I thought but, why can i use the UART for debug (Serial.println) but not for upload sketch?

Thanks.

How can i change baud rate on the USB to serial converter ? do you mean the usb to ttl device?


Thanks.
 

LesJones

Joined Jan 8, 2017
2,317
I have only ever played with an Arduino Uno and I just selected that in the tools menu. There does not seem to be an option for selecting the board rate. I think there are some versions of the Arduino that do not have a built in USB to serial converter so if one of those was selected in the tools menu there would probably be an option to select the USB to serial converter type and baud rate. USB to serial converters are also called USB to ttl.

Les.
 

LesJones

Joined Jan 8, 2017
2,317
I have never used the debug function so I have no idea how it works. I have not used my Arduino much as I find it much easier to program in assembler than "C".

Les.
 

Thread Starter

Luigi Santagada

Joined Jan 26, 2019
7
Hi,
I'm not using arduino boards, atmega328p microcontroller is not arduino board :).

I only use the arduino ide for upload a blink sketch and a cp2102 usb to ttl.

I can debug a sketch but i can't upload a sketch with the cp2102.
 

Norfindel

Joined Mar 6, 2008
325
Shouldn't the atmega not run at all, because the bootloader is configuring it to use a 16 mhz crystal, or ceramic oscillator, depending on the board?

It seems like you're not the only one trying to do that. In this page they offer a zip file to add an atmega328p with the internal 8 MHz oscillator as an "arduino board": https://www.instructables.com/id/Configure-Arduino-IDE-for-Atmega-328P-to-Use-8MHz-/
It seems to have some text files defining things like fuse settings, and a tweaked bootloader.
 

jayanthd

Joined Jul 4, 2015
902
You use a bootloader which is compiled for 16 MHz and so it will not work with 8 MHz crystal.
 

Norfindel

Joined Mar 6, 2008
325
On the atmega, you set the oscillator type thru the fuses. I don't think that it would boot at all if the fuses say that there's an external crystal/resonator/oscillator, but there isn't any connected.
 
Top