Arduino ISP and ATTiny2313 with external crystal

I have attiny2313 and arduino mega2560. I need to program mk with external crystal using arduino as isp programmer. I googled a lot but all, that I found, is examples how to program attiny2313 using internal oscillator 1 or 8 MHz.

Also I found fuse calculator and examples how to set fuses in boards.txt but it requires to set bootloader and some other specs and I don't want accidentally lock my attiny2313 with incorrect fuses or incorrect bootloader.

Is it possible to program attiny2313 with external crystal over arduino, or I need to buy external programmer? If yes, what changes I need to do in boards.txt, does it really need bootloader, or probably its possible to flash attiny without it?

Hi,

Attiny chip isnt that exp, I say go for external crystal and try , I have posted my lesson learnt with Atmega8 using both crystal and without it ( its not that reliable without one ).
Share your exp with us , the circuit is not that complicated. Use an old version I did with 0022 and it worked pretty well without having to modify any sorta file.

Thanks

You can use your mega2560 with ArduinoISP as a programmer.

You can start with this tiny core, https://code.google.com/p/arduino-tiny/

Then update the boards.txt file to add a definition for a 2313 with external crystal, low fuse=0xFF.

For IDE 1.0.x:

###########################################################################
###########################################################################

attiny2313at8.name=ATtiny2313 @ 8 MHz External Crystal

# The following do NOT work...
# attiny2313at8e.upload.using=avrispv2
# attiny2313at8e.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny2313at8e.upload.using=arduino:arduinoisp
# attiny2313at8e.upload.protocol=avrispv2
# attiny2313at8e.upload.using=pololu

attiny2313at8e.upload.maximum_size=2048

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Ext. Crystal Osc. 8 MHz; Start-up time: 14 CK + 65 ms; [CKSEL=0100 SUT=10]; default value 
# Brown-out detection disabled; [BODLEVEL=111]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny2313at8e.bootloader.low_fuses=0xFF
attiny2313at8e.bootloader.high_fuses=0x9F
attiny2313at8e.bootloader.extended_fuses=0xFF
attiny2313at8e.bootloader.path=empty
attiny2313at8e.bootloader.file=empty2313at8.hex

attiny2313at8e.build.mcu=attiny2313
attiny2313at8e.build.f_cpu=8000000L
attiny2313at8e.build.core=tiny

For IDE 1.6.x:

###########################################################################

attiny2313at8e.name=ATtiny2313 @ 8 MHz External Crystal

attiny2313at8e.upload.tool=arduino:arduinoisp
attiny2313at8e.upload.maximum_size=2048
attiny2313at8e.upload.maximum_data_size=128

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Ext. Crystal Osc. 8 MHz; Start-up time: 14 CK + 65 ms; [CKSEL=0100 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Serial program downloading (SPI) enabled; [SPIEN=0]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny2313at8e.bootloader.low_fuses=0xFF
attiny2313at8e.bootloader.high_fuses=0x9F
attiny2313at8e.bootloader.extended_fuses=0xFF
attiny2313at8e.bootloader.tool=arduino:avrdude
attiny2313at8e.bootloader.file=empty/empty2313at8.hex

attiny2313at8e.build.mcu=attiny2313
attiny2313at8e.build.f_cpu=8000000L
attiny2313at8e.build.core=tiny

hiduino, thanks, this is just what I’m looking for!

Sorry to bring up this old thread, but since I'm having a problem relating to this I'll give it a try.

I'm using the Attiny2313 with a 16MHz crystal with the fuses set accordingly, however I'm not able to get the serial communication to work properly. With 8MHz and 1MHz it works, but not with 16MHz.

I assume the problem lies in the line "attiny2313at1.bootloader.file=empty2313at8.hex", but I have not been able to find a hex file for 16MHz, is there a way around this?

##################################

attiny2313at1.name=ATtiny2313 @ 16 MHz

attiny2313at1.upload.tool=arduino:arduinoisp

attiny2313at1.upload.maximum_size=2048
attiny2313at1.upload.maximum_data_size=128

Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)

Int. RC Osc. 8 MHz; Start-up time: 14 CK + 65 ms; [CKSEL=0100 SUT=10]; default value

Divide clock by 8 internally; [CKDIV8=0]

Brown-out detection disabled; [BODLEVEL=111]

Serial program downloading (SPI) enabled; [SPIEN=0]

Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny2313at1.bootloader.low_fuses=0xFF
attiny2313at1.bootloader.high_fuses=0x9F
attiny2313at1.bootloader.extended_fuses=0xFF

attiny2313at1.bootloader.path=empty
attiny2313at1.bootloader.file=empty2313at8.hex
attiny2313at1.bootloader.tool=arduino:avrdude

attiny2313at1.build.mcu=attiny2313
attiny2313at1.build.f_cpu=16000000L
attiny2313at1.build.core=tiny

##################################

Lars81:
Sorry to bring up this old thread, but since I'm having a problem relating to this I'll give it a try.

I'm using the Attiny2313 with a 16MHz crystal with the fuses set accordingly, however I'm not able to get the serial communication to work properly. With 8MHz and 1MHz it works, but not with 16MHz.

I assume the problem lies in the line "attiny2313at1.bootloader.file=empty2313at8.hex", but I have not been able to find a hex file for 16MHz, is there a way around this?

The empty bootloaders are interchangable.
I have no idea what is in them - I replaced them recently in my core with an empty_all.hex with just a couple of bytes written (the only reason you need anything there is that the recipe in platform.txt specifies a flash file when burning bootloader to set fuses, and avrdude will barf if you tell it to write the flash but give it an empty file. So you need to give it something to chew on if the core has any files that actually do write a bootloader)

I would suggest using a custom core designed to support the chip you're using, like mine for example ( GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 ), which allows you to select internal or external clock source at a variety of common speeds (including 16mhz - and 20, 12, 8, 6 with crystal, 0.5, 1, 4, and 8 with internal) , and ought to just work ( I remember testing serial on it at several different system clock rates a while back, and haven't touched anything related to x313 )

If you get the same results with my core, go ahead and create an issue in github; this should absolutely work!

DrAzzy:
The empty bootloaders are interchangable.
I have no idea what is in them - I replaced them recently in my core with an empty_all.hex with just a couple of bytes written (the only reason you need anything there is that the recipe in platform.txt specifies a flash file when burning bootloader to set fuses, and avrdude will barf if you tell it to write the flash but give it an empty file. So you need to give it something to chew on if the core has any files that actually do write a bootloader)

I would suggest using a custom core designed to support the chip you're using, like mine for example ( GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 ), which allows you to select internal or external clock source at a variety of common speeds (including 16mhz - and 20, 12, 8, 6 with crystal, 0.5, 1, 4, and 8 with internal) , and ought to just work ( I remember testing serial on it at several different system clock rates a while back, and haven't touched anything related to x313 )

If you get the same results with my core, go ahead and create an issue in github; this should absolutely work!

I'll try it.

Just to clarify here, but the way I tested the serial communication was to make a sketch like this (from memory as I don't have it on this computer):

void setup(){
Serial.begin(115200);
}

void loop(){
static unsigned int number = 0;
Serial.println(number++);
}

Then I used the serial monitor to check if it worked.
This was however the only baud rate that worked (on 1MHz and 8MHz mode), why is that?