Hi all
Can anyone tell me why I read 2 different freq. in these two datasheets?
16MHz
vs
20MHz
And another thing: is ATMEGA328P-PU the same as ATMEGA328P regarding the bootloader?
Thanks
Hi all
Can anyone tell me why I read 2 different freq. in these two datasheets?
16MHz
vs
20MHz
And another thing: is ATMEGA328P-PU the same as ATMEGA328P regarding the bootloader?
Thanks
Because they are different grades of chip, Automotive v Standard.
They work the same, but have different signatures for programming the bootloader onto them, once it is on, the bootloader will report the same signature. Hope this helps.
I still have dubts...
Can I use a 16MHz crystal oscillator as a 20MHz one with the same uC?
Are the 2 bootloaders different?
ATmega328P is the general model name for the microcontroller. There is also a prefix that indicates the IC package that is used.
So when we say "ATmega328P", we are referring to the microcontroller in general, which includes all packaged forms of that silicon.
When we say "ATmega328P-PU", we are referring to the ATmega328P in the PDIP-28 IC package specifically. This lovely thing:
You can learn all the details by checking section 38.8 of the "ATmega48A/PA/88A/PA/168A/PA/328/P" datasheet, available for download here:
https://www.microchip.com/en-us/product/ATmega328P#document-table
Your question is unclear. If you are asking whether you can use a 20 MHz crystal oscillator with the ATmega328P microcontroler, the answer is "yes", as long as you are powering it at 4.5 V or higher.
Yes. The bootloader must be compiled for the clock speed the microcontroller will run at.
The reason is that the bootloader does serial communication with your computer at a specific baud rate (typically 115200 baud). The timings are dependent on the clock speed the chip is running at, and those timings are determined at compile time. So if you use the bootloader compiled for 16 MHz on a chip running at 20 MHz then the actual baud rate of the chip's serial communication would be 144000 baud (115200 x 20 / 16) instead of the expected 115200 and it would not be able to communicate with the computer.
The easiest way to get the ATmega328P bootloader precompiled for 20 MHz is by using the excellent "MiniCore" Arduino boards platform.
I'll provide instructions:
MiniCore is a 3rd party boards platform that adds support to the Arduino IDE for many configurations of the family of AVR microcontrollers including the ATmega328P. It can be installed very easily using the Arduino IDE Boards Manager.
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
If there are already Additional Boards Manager URLs there, separate them with commas.The installation of MiniCore has added some new boards options to the Arduino IDE. You must now select them.
You will notice that some additional custom configuration menus have been added under the Tools menu after selecting the "ATmega328" board. You can adjust those according to your needs as well.
You will need an ISP programmer. If you don't have a programmer, you can use a spare Arduino board as an "Arduino as ISP" programmer.
The following instructions are for using an Arduino board as an "Arduino as ISP" programmer. If you have a dedicated programmer, you can skip to the next set of instructions.
Although the "Arduino as ISP" only works for programming targets of the AVR architecture, you can also use boards of a variety of architectures (e.g., "AVR", "SAMD", "megaAVR") as an "Arduino as ISP" programmer.
I will refer to the board which will used as an "Arduino as ISP" as the "programmer board" from here on. The board you are burning the bootloader to will be referred to as the "target board".
Programmer | Target |
---|---|
MISO | MISO |
VCC | 5V (VCC on 3.3 V boards) |
SCK | SCK |
MOSI | MOSI |
10 | RESET |
GND | GND |
You are now ready to burn the bootloader using your "Arduino as ISP" programmer.
Instructions for burning the bootloader:
Now connect the USB cable of the "target board" to your computer, select its port from the Tools > Port menu, and try uploading a sketch as usual.
There is detailed documentation about all of this in the MiniCore readme:
I mean can I put indifferently a 16MHz or a 20MHz quartz on the Arduino board I want to design along with 2 22pF caps as long as the bootloader is written accordingly? In the datasheet mentioning 20MHz as the freq it is not mentioned 16MHz and viceversa.
Yes. There is a range of supported clock speeds. You will see 20 MHz mentioned as the maximum of that range, but lower clock speeds are also supported. MiniCore provides boards definitions for the frequencies that are most likely to be used:
https://github.com/MCUdude/MiniCore#supported-clock-frequencies
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.