Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a AtMega328p from another Arduino device #20

Open
Rudis1261 opened this issue Mar 29, 2022 · 5 comments
Open

Using a AtMega328p from another Arduino device #20

Rudis1261 opened this issue Mar 29, 2022 · 5 comments

Comments

@Rudis1261
Copy link

Rudis1261 commented Mar 29, 2022

So after some research, I found how to set the 328p fuse to use the internal clock in case you want to repurpose an Arduino with a suitable chip like a lilypad, or nano or something similar. You need to set this fuse back to factory because Arduinos by default get switched to an external clock instead of it's internal one.

You will need to hook up the Arduino on the ICSP headers, and use another Arduino programmed as an Arduino as ISP to program the target 328p board.

And you need to set the fuse prior to de-soldering the chip from the Arduino to use in the solder reflow plate. Otherwise you will not be able to program it from the ICSP headers once on the solder reflow plate.

Using this command you can set the fuse to tell the Arduino to use the internal clock:

~/AppData/Local/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude.exe \
-PCOM8 \
-v \
-patmega328p \
-cstk500v1 \
-PCOM8 \
-b19200 \
-C avrdude.conf \
-U lfuse:w:0xF2:m

The command broken down:

# The path of your avrdude.exe file 
~/AppData/Local/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude.exe
# The COM port where the Arduino as ISP can be found
-PCOM8
# Verbose output
-v
# The target chip
-patmega328p
# The programmer avr should use
-cstk500v1
# The baud rate as set in the Arduino as ISP sketch uploaded to the programming Arduino
-b19200
# The avrdude.conf, this may not be in the same directory as the command.
-C avrdude.conf
# The action to perform, in this case we are setting the LFUSE to `0xF2` by writing the value to configure the 328p to use the internal clock.
-U lfuse:w:0xF2:m

Hope this helps someone.

A great video explaining this, and what got me to an answer:
https://www.youtube.com/watch?v=Q2DakPocvfs

@Rudis1261 Rudis1261 changed the title Using a AtMega328p from another arduino device Using a AtMega328p from another Arduino device Mar 29, 2022
@doskoi
Copy link

doskoi commented Mar 31, 2022

Thanks for the useful material, this doc do the same thing in another approach https://docs.arduino.cc/built-in-examples/arduino-isp/ArduinoToBreadboard/

@doskoi
Copy link

doskoi commented Apr 1, 2022

Or from the comments inside the source code

To program
 *  1) Select the following settings under (Tools)
 *      Board->Minicore->Atmega328 
 *      Clock->Internal 8MHz
 *      BOD->BOD 2.7V
 *      EEPROM->EEPROM retained
 *      Compiler LTO->LTO Disabled
 *      Variant->328P / 328PA
 *      Bootloader->No bootloader
 *  2) Set programmer of choice, e.g.'Arduino as ISP (MiniCore)', 'USB ASP', etc, and set correct port.
 *  3) Burn bootloader (to set fuses correctly)
 *  4) Compile and upload

@doskoi
Copy link

doskoi commented Apr 1, 2022

I was upload without set fuse nor use minicore to set internal clock but just sodering chip on this board,
Then I'm using breadboard with DIP 16M external clock attach to XTAL1 and XTAL2 (PIN7, 8), after this I can comminucate with 328p by programmer again.

@simonstrachan
Copy link

I had my boards assembled with the Atmega already on them. Is there a way to do what GreatScott did in his video with a function generator? I can not seem to be able to get the bootloader to sync. Is it only possible to do it with an external clock or taking one from an existing Arduino?

@doskoi
Copy link

doskoi commented Aug 29, 2023

You need to follow the setup at above to enable built-in clock.

Clock->Internal 8MHz

For your circumstance, you need a external clock to do this setup work. after that, you won't need external clock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants