- •Features
- •Pin Configurations
- •Overview
- •Block Diagram
- •Pin Descriptions
- •Port A (PA2..PA0)
- •Port B (PB7..PB0)
- •Port D (PD6..PD0)
- •RESET
- •XTAL1
- •XTAL2
- •Disclaimer
- •AVR CPU Core
- •Introduction
- •Architectural Overview
- •Status Register
- •Stack Pointer
- •Interrupt Response Time
- •SRAM Data Memory
- •Data Memory Access Times
- •EEPROM Data Memory
- •EEPROM Read/Write Access
- •Atomic Byte Programming
- •Split Byte Programming
- •Erase
- •Write
- •I/O Memory
- •General Purpose I/O Registers
- •Clock Systems and their Distribution
- •Clock Sources
- •Default Clock Source
- •Crystal Oscillator
- •External Clock
- •Idle Mode
- •Power-down Mode
- •Standby Mode
- •Analog Comparator
- •Brown-out Detector
- •Internal Voltage Reference
- •Watchdog Timer
- •Port Pins
- •Resetting the AVR
- •Reset Sources
- •Power-on Reset
- •External Reset
- •Brown-out Detection
- •Watchdog Reset
- •Watchdog Timer
- •Interrupts
- •I/O-Ports
- •Introduction
- •Configuring the Pin
- •Toggling the Pin
- •Reading the Pin Value
- •Alternate Port Functions
- •Alternate Functions of Port A
- •Alternate Functions of Port B
- •Alternate Functions of Port D
- •Register Description for I/O-Ports
- •External Interrupts
- •8-bit Timer/Counter0 with PWM
- •Overview
- •Registers
- •Definitions
- •Counter Unit
- •Output Compare Unit
- •Force Output Compare
- •Modes of Operation
- •Normal Mode
- •Fast PWM Mode
- •Phase Correct PWM Mode
- •Internal Clock Source
- •Prescaler Reset
- •External Clock Source
- •16-bit Timer/Counter1
- •Overview
- •Registers
- •Definitions
- •Compatibility
- •Counter Unit
- •Input Capture Unit
- •Input Capture Trigger Source
- •Noise Canceler
- •Using the Input Capture Unit
- •Output Compare Units
- •Force Output Compare
- •Modes of Operation
- •Normal Mode
- •Fast PWM Mode
- •Phase Correct PWM Mode
- •USART
- •Overview
- •Clock Generation
- •External Clock
- •Synchronous Clock Operation
- •Frame Formats
- •Parity Bit Calculation
- •USART Initialization
- •Sending Frames with 5 to 8 Data Bit
- •Sending Frames with 9 Data Bit
- •Parity Generator
- •Disabling the Transmitter
- •Receiving Frames with 5 to 8 Data Bits
- •Receiving Frames with 9 Data Bits
- •Receiver Error Flags
- •Parity Checker
- •Disabling the Receiver
- •Flushing the Receive Buffer
- •Asynchronous Data Recovery
- •Using MPCM
- •Overview
- •Functional Descriptions
- •Three-wire Mode
- •SPI Slave Operation Example
- •Two-wire Mode
- •Start Condition Detector
- •Alternative USI Usage
- •4-bit Counter
- •12-bit Timer/Counter
- •Software Interrupt
- •Analog Comparator
- •debugWIRE On-chip Debug System
- •Features
- •Overview
- •Physical Interface
- •Software Break Points
- •Limitations of debugWIRE
- •debugWIRE Related Register in I/O Memory
- •Performing a Page Write
- •Reading the Fuse and Lock Bits from Software
- •Preventing Flash Corruption
- •Fuse Bits
- •Latching of Fuses
- •Signature Bytes
- •Calibration Byte
- •Page Size
- •Signal Names
- •Parallel Programming
- •Enter Programming Mode
- •Chip Erase
- •Programming the Flash
- •Programming the EEPROM
- •Reading the Flash
- •Reading the EEPROM
- •Programming the Lock Bits
- •Reading the Signature Bytes
- •Reading the Calibration Byte
- •Serial Downloading
- •Electrical Characteristics
- •Absolute Maximum Ratings*
- •DC Characteristics
- •External Clock Drive Waveforms
- •External Clock Drive
- •Active Supply Current
- •Idle Supply Current
- •Power-down Supply Current
- •Standby Supply Current
- •Pin Pull-up
- •Pin Driver Strength
- •Internal Oscillator Speed
- •Register Summary
- •Instruction Set Summary
- •Ordering Information
- •Packaging Information
- •Errata
- •ATtiny2313 Rev B
- •ATtiny2313 Rev A
- •Changes from Rev. 2514F-08/04 to Rev. 2514G-10/04
- •Changes from Rev. 2514F-08/04 to Rev. 2514G-10/04
- •Changes from Rev. 2514E-04/04 to Rev. 2514F-08/04
- •Changes from Rev. 2514D-03/04 to Rev. 2514E-04/04
- •Changes from Rev. 2514C-12/03 to Rev. 2514D-03/04
- •Changes from Rev. 2514B-09/03 to Rev. 2514C-12/03
- •Changes from Rev. 2514A-09/03 to Rev. 2514B-09/03
- •Table of Contents
EEPROM Write Prevents |
|
|
|
|
|
|
|
|
|
|
|
Note that an EEPROM write operation will block all software programming to Flash. |
|||||
Writing to SPMCSR |
Reading the Fuses and Lock bits from software will also be prevented during the |
||||
|
EEPROM write operation. It is recommended that the user checks the status bit (EEWE) |
||||
|
in the EECR Register and verifies that the bit is cleared before writing to the SPMCSR |
||||
|
Register. |
Reading the Fuse and Lock Bits from Software
It is possible to read both the Fuse and Lock bits from software. To read the Lock bits, load the Z-pointer with 0x0001 and set the RFLB and SELFPRGEN bits in SPMCSR. When an LPM instruction is executed within three CPU cycles after the RFLB and SELFPRGEN bits are set in SPMCSR, the value of the Lock bits will be loaded in the destination register. The RFLB and SELFPRGEN bits will auto-clear upon completion of reading the Lock bits or if no LPM instruction is executed within three CPU cycles or no SPM instruction is executed within four CPU cycles. When RFLB and SELFPRGEN are cleared, LPM will work as described in the Instruction set Manual.
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|
Rd |
– |
– |
– |
– |
– |
– |
LB2 |
LB1 |
|
|
|
|
|
|
|
|
|
|
|
The algorithm for reading the Fuse Low byte is similar to the one described above for reading the Lock bits. To read the Fuse Low byte, load the Z-pointer with 0x0000 and set the RFLB and SELFPRGEN bits in SPMCSR. When an LPM instruction is executed within three cycles after the RFLB and SELFPRGEN bits are set in the SPMCSR, the value of the Fuse Low byte (FLB) will be loaded in the destination register as shown below. Refer to Table 68 on page 160 for a detailed description and mapping of the Fuse Low byte.
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Rd |
FLB7 |
FLB6 |
FLB5 |
FLB4 |
FLB3 |
FLB2 |
FLB1 |
FLB0 |
|
|
|
|
|
|
|
|
|
Similarly, when reading the Fuse High byte, load 0x0003 in the Z-pointer. When an LPM instruction is executed within three cycles after the RFLB and SELFPRGEN bits are set in the SPMCSR, the value of the Fuse High byte (FHB) will be loaded in the destination register as shown below. Refer to Table XXX on page xxx for detailed description and mapping of the Fuse High byte.
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
Rd |
FHB7 |
FHB6 |
FHB5 |
FHB4 |
FHB3 |
FHB2 |
FHB1 |
FHB0 |
|
|
|
|
|
|
|
|
|
Fuse and Lock bits that are programmed, will be read as zero. Fuse and Lock bits that are unprogrammed, will be read as one.
156 ATtiny2313/V
2543H–AVR–02/05
ATtiny2313/V
Preventing Flash Corruption During periods of low VCC, the Flash program can be corrupted because the supply voltage is too low for the CPU and the Flash to operate properly. These issues are the same as for board level systems using the Flash, and the same design solutions should be applied.
A Flash program corruption can be caused by two situations when the voltage is too low. First, a regular write sequence to the Flash requires a minimum voltage to operate correctly. Secondly, the CPU itself can execute instructions incorrectly, if the supply voltage for executing instructions is too low.
Flash corruption can easily be avoided by following these design recommendations (one is sufficient):
1.Keep the AVR RESET active (low) during periods of insufficient power supply voltage. This can be done by enabling the internal Brown-out Detector (BOD) if
the operating voltage matches the detection level. If not, an external low VCC reset protection circuit can be used. If a reset occurs while a write operation is in progress, the write operation will be completed provided that the power supply voltage is sufficient.
2.Keep the AVR core in Power-down sleep mode during periods of low VCC. This will prevent the CPU from attempting to decode and execute instructions, effectively protecting the SPMCSR Register and thus the Flash from unintentional writes.
Programming Time for Flash The calibrated RC Oscillator is used to time Flash accesses. Table 63 shows the typical
when Using SPM |
programming time for Flash accesses from the CPU. |
|
|
|
Table 63. SPM Programming Time |
|
|
|
|
|
|
|
Symbol |
Min Programming Time |
Max Programming Time |
|
|
|
|
|
Flash write (Page Erase, Page Write, |
3.7 ms |
4.5 ms |
|
and write Lock bits by SPM) |
||
|
|
|
|
|
|
|
|
157
2543H–AVR–02/05
Memory
Programming
Program And Data
Memory Lock Bits
The ATtiny2313 provides two Lock bits which can be left unprogrammed (“1”) or can be programmed (“0”) to obtain the additional features listed in Table 65. The Lock bits can only be erased to “1” with the Chip Erase command.
Table 64. Lock Bit Byte(1)
|
Lock Bit Byte |
Bit No |
Description |
Default Value |
|
|
|
|
|
|
|
7 |
– |
1 (unprogrammed) |
|
|
|
|
|
|
|
6 |
– |
1 (unprogrammed) |
|
|
|
|
|
|
|
5 |
– |
1 (unprogrammed) |
|
|
|
|
|
|
|
4 |
– |
1 (unprogrammed) |
|
|
|
|
|
|
|
3 |
– |
1 (unprogrammed) |
|
|
|
|
|
|
|
2 |
– |
1 (unprogrammed) |
|
|
|
|
|
LB2 |
|
1 |
Lock bit |
1 (unprogrammed) |
|
|
|
|
|
LB1 |
|
0 |
Lock bit |
1 (unprogrammed) |
|
|
|
|
|
Note: |
1. “1” means unprogrammed, “0” means programmed |
|
Table 65. Lock Bit Protection Modes(1)(2)
Memory Lock Bits |
|
Protection Type |
||
|
|
|
|
|
LB Mode |
LB2 |
|
LB1 |
|
|
|
|
|
|
1 |
1 |
|
1 |
No memory lock features enabled. |
|
|
|
|
|
|
|
|
|
Further programming of the Flash and EEPROM is |
2 |
1 |
|
0 |
disabled in Parallel and Serial Programming mode. The |
|
Fuse bits are locked in both Serial and Parallel |
|||
|
|
|
|
|
|
|
|
|
Programming mode.(1) |
|
|
|
|
Further programming and verification of the Flash and |
3 |
0 |
|
0 |
EEPROM is disabled in Parallel and Serial Programming |
|
mode. The Boot Lock bits and Fuse bits are locked in both |
|||
|
|
|
|
|
|
|
|
|
Serial and Parallel Programming mode.(1) |
Notes: 1. Program the Fuse bits and Boot Lock bits before programming the LB1 and LB2. 2. “1” means unprogrammed, “0” means programmed
158 ATtiny2313/V
2543H–AVR–02/05