# Use an ATtiny85 instead of an ATtiny13 - Where do I place the XTAL?

Having looked at a circuit diagram in Beginners Introduction to the Assembly Language of ATMEL­ AVR ­Microprocessors by Gerhard Schmidt, I came across a circuit presented by the author (in which an ATtiny13) is used, as below:

Having then looked at Wikipedia's comparison chart, the ATMEL datasheet (Pgs. 29-30) and elsewhere, the only differences between the two packages I can see are:

1. The '85 has more flash, RAM and EEPROM memory than the '13
2. The '85 requires can use a crystal oscillator (XTAL) or a ceramic resonator connected to pins 3 (Out) and 2 (In), as shown on page 29.

This lead me to modify the schematic to add the crystal, but I'm not sure if I've altered it correctly.

simulate this circuit – Schematic created using CircuitLab

The question I have is this: Is the modification I've made to Schmidt's schematic (adding the crystal and 16pF caps) correct in order for the '13 to be replaced with an '85? (Assume that, physically, the bridge rectifier and VREG portion sit closer to the LED and caps for the crystal, reducing the amount of GND trace between them.)

EDIT 1: Having read the comments and Choosing the Right Crystal and Caps for your Design, I have come to be aware of the following:

1. An XTAL has a load capacitance, calculated as CL = (C1*C2) / (C1 + C2) + Cstray
2. A better way of calculating C1 and C2 is C1, C2 = 2*CL - 2*CStray
3. The XTAL should be placed as close to the pins as possible (theoretically directly connected to the pins, but in the next holes, for the practical reason of not soldering to the chip's pins).
4. Cstray can be estimated to be between 2pF and 5pF. (That leaves a margin of error of about 6pF, which seems more than negligible to me.)

This adds a second part to the question: Is there any way to determine/measure (with some accuracy/small margin of error) what Cstray will be, in order to determine what C1 and C2 will be?

Edit 2: I have also looked at this question about appropriate caps to use for a microcontroller

• The ATtiny85 does not require a crystal. It can utilize one, but that is only needed if you need accurate timing. Its fastest peripherals modes are actually only obtainable without. If you are going to use one, while your circuit might be correct in terms of connectivity, it does not suggest a sound understanding of crystal layout concerns, for example minimizing loop area. Have a look at some actual designs. For that matter your schematic has no real organization - it portrays neither clear functionality nor physical geometry. – Chris Stratton Jun 7 '18 at 20:51
• Thank you, @ChrisStratton. My main concern was whether the circuit is correct in terms of the crystal's connectivity (although I'll admit the schematic is hard to follow). – Agi Hammerthief Jun 7 '18 at 21:00
• why is the schematic so convoluted? .... just separating the ground net would make the schematic more readable – jsotola Jun 7 '18 at 21:44