Instead of using the regular Arduino board I have purchased the atmega328p-pu along with this components:
- 22pf ceramic capacitor
- 10K resistor
- 16mhz crystal
- 47uF capacitor
- 3.3 Volts Power supply
The diagram looks like this:
Because the atmega328p chip that I purchased already comes loaded with arduino bootloader I can program this chip right away! This video explains in more detail how to upload the code to the chip. It is very simple.
The reason why I run my atmega328p chip with a 3.3V power supply is because of these reasons:
- I have multiple sensors like the NRF24L01 that cannot take 5 volts.
- I run this project of a 3.3 battery as well in order to save power.
- I do not want to use voltage regulators as they are inefficient and they will waste my battery.
- Everything works great.
Even though everything works great if I am running atmega328P at 16mhz @ 3.3V I am not following the specifications. In order to do things correct I will like to run my code at 8mhz so that I am in within the specs
What is the correct way of running this project at 8mhz? If I change the 16mhz crystal for a 8mhz it runs at 8mhz but everything is half the speed. I have to divide all time related functions by 2. Moreover, I cannot upload new code if it has a 8mhz crystal. In order to upload new code I have to place the 16mhz crystal upload the code and then change the crystal again.
Can I still use my 16mhz crystal and run at 8mhz so that I do not have to keep replacing the crystal? I want my
millis function and other time dependent functions to have the correct time. I do not want to have to divide everything by 2.
Do I have to burn a different bootloader for this to work? Where can I find a tutorial that can explain me all this?
There are tutorials on how to use the internal 8mhz crystal from the atmega328 chip but still want to use an external crystal as it is much more accurate
I just found this link that explains how to do it. Edgar Bonet answer seems a lot simpler so I will stick to that.