Bascom and AVR, Using the ATTiny2313
Make sure you have TWinAvr version 1.1 or later. TWinAvr 1.0 had a problem with recognising the ATTiny2313.
Atmel now calls the AT90S2313 a
product. I am not sure what this ominous description
precisely means, but the fact is that it is still widely available. Atmel of course does not recommend
the AT90S2313 for new designs and states that the ATTiny2313 is the replacement to use.
However, the ATTiny2313 is a bit different. Make sure you read the
as well as Atmel's application note on
replacing the AT90S2313 with the ATTiny2313.
The most important difference is that the ATTiny2313 has much more fuse settings. To get started,
note that with a blank (unused) ATTiny2313 the clock will be sourced from an internal 8MHz RC oscillator, prescaled
by 8, resulting in a 1MHz clock.
If you are used to the default TWinAvr setting of 4MHz:
TWinAvr will probably too fast to program the ATTiny2313.
Start with lowering the TWinAvr clock to a safe 500kHz:
Use the ATTiny2313 in the following schematic (the same as used in:
and and click in the TWinAVR window on Config. The fuse settings appear:
Now, if you want to keep things as they are, just use TWinAvr with its 500kHz clock. If you want to
use the ATTiny2313 as a replacement for the AT90S2313 in the schematics on these web-pages,
you should change the fuses as follows:
As soon as you change the fuses, the crystal oscillator starts running at 4MHz. The voltage
level on pin 5 (XTAL1) is only app. 1Vtt:
compare this to the 4Vtt on pin 5 of the AT90S2313:
This also means that you cannot use pin 4 (XTAL2) to drive another AVR. If you must do this,
you will have to unprogram the CKOUT fuse to enable clock output on 6, but that means
sacrifycing PortD.2 which is of course most inconvenient.
Other differences are:
- the possible use of the reset, xtal1 and xtal2 pins as general purpose I/O portA. This can of course only be done when the ATTiny2313 runs on its internal RC clock.
- using PortD pins to generate an interrupt on level change
- using Reset as "debugWire", This uses the Reset line as a bi-directional interface to control
how the program executes. This could be used as a simple emulator with symbolic debugging.
Bascom does however not (yet) support these options.