Hello,
long story short, my objective is the following: I'm making a project in which would be nice to work with 8 Mhz (preferably using the internal clock), as I plan it to be supplied by a 3V battery.
Since I generally lack on technical knowledge about these in-depth things, I preferred to do exactely as stated in the guides, but I didn't try to "correct the errors", since I don't know at all where should I go, and the other posts I searched into confused me more. So, I hoped that someone would have the patience to help me on my specific problem, but I'll try to be as detailed as possible. (Sorry if it's gonna be a kinda long question)
I leave some specs so it's more clear what I'm using:
- chip: ATMega328P-PU
- board: Arduino UNO rev. 3
- IDE: Arduino IDE 1.8.13
- for the work, I tried using Minicore v2.1.3
- OS: Ubuntu 20.04 LTS (in case you need to redirect me to some folder, idk)
- consider also that I don't have any external programmer or simila, and I hope I can achive my goal without having to buy any of those things
General overview
From the beginning: the ATMega328P I bought is already bootloaded for 16 MHz for my Arduino UNO (aka. I bought it, I inserted it in the board and it was ready to be used). As stated before, however, when working on my project I wanted to switch to 8 MHz, mainly because of the supply voltage (the whole system runs on 3V, so it kinda bothers me that I need to supply 5V just for the ATMega, which will run as a standalone chip; I already managed to make it work fine, at least on 16 MHz).
I found out two main ways to change my operating frequency:
- by using this guide found on the Arduino website
https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoToBreadboard - by using MiniCore, which is the way I'm currently focusing on
GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
I'll describe them both.
With the ArduinoToBreadboard guide
First doubt, probably very stupid: as I tried to install all the breadboard-1.x.x.zip, I found out that only breadboard-1.0.x.zip gets recognized by the IDE, which I found strange, since I imagined that the last version was more likely to work (as I didn't find a successive version, I thought that breadboard-1.6.x.zip was the one still used).
Anyway, I tried the procedure, and just by selecting Tools > Board > ATmega328 on a breadboard (8 MHz internal clock) i get this
The current selected board needs the core 'arduino:arduino' that is not installed.
and I didn't find a single way on what to do next. Obviously, even by following the instructions anyway and trying to burn the bootloader, it doesn't work
Arduino: 1.8.13 (Linux), Board: "ATmega328 on a breadboard (8 MHz internal clock)"
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:329)
at processing.app.Editor.lambda$handleBurnBootloader$61(Editor.java:2379)
at java.lang.Thread.run(Thread.java:748)
Error while burning bootloader.
I didn't went further, as I had doubt with this method from the start. But if you can enlighten me, then thank you.
With the MiniCore guide
Uploading the program on the IDE went nice and easy. But the first problem came quickly: as shown here GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB I went with using the first wiring diagram (since my ATMega is a DIP28 package). The problem is that I didn't really know what the sections "UART" and "AVR ISP" were, but by searching I found out that they are the same (am I right here?) as the ones shown here
https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoToBreadboard#minimal-circuit-eliminating-the-external-clock
In other words, the pins seems connected in the same way as the ones on the ArduinoToBreadboard guide. Also, since I don't have a 8 MHz crystal right now, I assumed I could not use it, since my objective was not to have an external crystal (probably a terrible reasoning, but trust me if I say if I'm completely lost). So I went with that configuration instead, as otherwise I don't really know what those UART and AVR ISP pins are on the Arduino UNO board (if they really are there).
I decided anyway to give it a go with these configs on the IDE
leaving almost anything untouched. The only thing I changed was the BOD, as I've understood it's related to the chip shutdown once this supply voltage is reached (if I understood right). I left it with a low value in order not to interfere with the fact that the battery discharges.
Burning the bootloader didn't work, as I had this output:
/home/verdefluox/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude -C/home/verdefluox/.arduino15/packages/MiniCore/hardware/avr/2.1.3/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0b11111110:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0xe2:m
avrdude: Version 6.3-20201216
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg WunschSystem wide configuration file is "/home/verdefluox/.arduino15/packages/MiniCore/hardware/avr/2.1.3/avrdude.conf" User configuration file is "/home/verdefluox/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyACM0 Using Programmer : stk500v1 Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
So I'm stuck here, and I have no idea on how to proceed.
About this method, however, I have one "preliminary" question that I can correct quickly (and it's not software related): what is the correct wiring diagram that I should follow? And do I really need the external crystal for uploading the new bootloader (if I'm planning to use the internal instead)?
Also: in the MiniCore GitHub page, at the very end of the page, I saw this written:
If you don't want to mess with breadboards, components and wiring; simply use your Arduino UNO!
Does this mean that I can do all the procedure with the ATMega328 inserted into the UNO board?
I know that an answer is gonna take some time, but I hope someone can help me, maybe step by step, if I'm not asking too much. Obviously I'll try everything you suggest me and I'll try to explain everything I do and I see.
P.S. I can also consider using an external 8 MHz crystal, since in the end my biggest goal is to make it run at 3V in some way (and 16 MHz is no good for that voltage).