ATmega8 (961730), страница 48
Текст из файла (страница 48)
Pin Mapping Serial ProgrammingSymbolPinsI/ODescriptionMOSIPB3ISerial data inMISOPB4OSerial data outSCKPB5ISerial clockFigure 112. Serial Programming and Verify(1)+2.7 - 5.5VVCCMOSIPB3MISOPB4SCKPB5+2.7 - 5.5V (2)AVCCXTAL1RESETGNDNotes:1. If the device is clocked by the Internal Oscillator, it is no need to connect a clocksource to the XTAL1 pin.2. VCC - 0.3 < AVCC < VCC + 0.3, however, AVCC should always be within 2.7 - 5.5V.When programming the EEPROM, an auto-erase cycle is built into the self-timed programming operation (in the Serial mode ONLY) and there is no need to first execute theChip Erase instruction. The Chip Erase operation turns the content of every memorylocation in both the Program and EEPROM arrays into 0xFF.Depending on CKSEL Fuses, a valid clock must be present. The minimum low and highperiods for the Serial Clock (SCK) input are defined as follows:Low:> 2 CPU clock cycles for fck < 12 MHz, 3 CPU clock cycles for fck ≥ 12 MHzHigh:> 2 CPU clock cycles for fck < 12 MHz, 3 CPU clock cycles for fck ≥ 12 MHz234ATmega8(L)2486O–AVR–10/04ATmega8(L)Serial ProgrammingAlgorithmWhen writing serial data to the ATmega8, data is clocked on the rising edge of SCK.When reading data from the ATmega8, data is clocked on the falling edge of SCK.
SeeFigure 113 for timing details.To program and verify the ATmega8 in the Serial Programming mode, the followingsequence is recommended (See four byte instruction formats in Table 98):1. Power-up sequence:Apply power between VCC and GND while RESET and SCK are set to “0”. Insome systems, the programmer can not guarantee that SCK is held low duringPower-up. In this case, RESET must be given a positive pulse of at least twoCPU clock cycles duration after SCK has been set to “0”.2. Wait for at least 20 ms and enable Serial Programming by sending the Programming Enable serial instruction to pin MOSI.3.
The Serial Programming instructions will not work if the communication is out ofsynchronization. When in sync. the second byte (0x53), will echo back whenissuing the third byte of the Programming Enable instruction. Whether the echois correct or not, all four bytes of the instruction must be transmitted. If the 0x53did not echo back, give RESET a positive pulse and issue a new ProgrammingEnable command.4. The Flash is programmed one page at a time. The page size is found in Table 89on page 222. The memory page is loaded one byte at a time by supplying the 5LSB of the address and data together with the Load Program memory Pageinstruction. To ensure correct loading of the page, the data Low byte must beloaded before data High byte is applied for a given address.
The Program memory Page is stored by loading the Write Program memory Page instruction withthe 7 MSB of the address. If polling is not used, the user must wait at leasttWD_FLASH before issuing the next page. (See Table 97).Note: If other commands than polling (read) are applied before any write operation(FLASH, EEPROM, Lock Bits, Fuses) is completed, it may result in incorrectprogramming.5. The EEPROM array is programmed one byte at a time by supplying the addressand data together with the appropriate Write instruction. An EEPROM memorylocation is first automatically erased before new data is written.
If polling is notused, the user must wait at least tWD_EEPROM before issuing the next byte. (SeeTable 97 on page 236). In a chip erased device, no 0xFFs in the data file(s) needto be programmed.6. Any memory location can be verified by using the Read instruction which returnsthe content at the selected address at serial output MISO.7. At the end of the programming session, RESET can be set high to commencenormal operation.8.
Power-off sequence (if needed):Set RESET to “1”.Turn VCC power offData Polling FlashWhen a page is being programmed into the Flash, reading an address location withinthe page being programmed will give the value 0xFF. At the time the device is ready fora new page, the programmed value will read correctly. This is used to determine whenthe next page can be written. Note that the entire page is written simultaneously and anyaddress within the page can be used for polling. Data polling of the Flash will not workfor the value 0xFF, so when programming this value, the user will have to wait for atleast tWD_FLASH before programming the next page. As a chip-erased device contains2352486O–AVR–10/040xFF in all locations, programming of addresses that are meant to contain 0xFF, can beskipped.
See Table 97 for tWD_FLASH value.Data Polling EEPROMWhen a new byte has been written and is being programmed into EEPROM, reading theaddress location being programmed will give the value 0xFF. At the time the device isready for a new byte, the programmed value will read correctly. This is used to determine when the next byte can be written. This will not work for the value 0xFF, but theuser should have the following in mind: As a chip-erased device contains 0xFF in alllocations, programming of addresses that are meant to contain 0xFF, can be skipped.This does not apply if the EEPROM is Re-programmed without chip-erasing the device.In this case, data polling cannot be used for the value 0xFF, and the user will have towait at least tWD_EEPROM before programming the next byte.
See Table 97 for tWD_EEPROMvalue.Table 97. Minimum Wait Delay Before Writing the Next Flash or EEPROM LocationSymbolMinimum Wait DelaytWD_FUSE4.5 mstWD_FLASH4.5 mstWD_EEPROM9.0 mstWD_ERASE9.0 msFigure 113. Serial Programming WaveformsSERIAL DATA INPUT(MOSI)MSBLSBSERIAL DATA OUTPUT(MISO)MSBLSBSERIAL CLOCK INPUT(SCK)SAMPLE236ATmega8(L)2486O–AVR–10/04ATmega8(L)Table 98.
Serial Programming Instruction SetInstruction FormatInstructionByte 1Byte 2Byte 3Byte4Programming Enable1010 11000101 0011xxxx xxxxxxxx xxxxEnable Serial Programming afterRESET goes low.Chip Erase1010 1100100x xxxxxxxx xxxxxxxx xxxxChip Erase EEPROM and Flash.Read Program Memory0010 H0000000 aaaabbbb bbbboooo ooooRead H (high or low) data o fromProgram memory at word addressa:b.Load Program MemoryPage0100 H0000000 xxxxxxxb bbbbiiii iiiiWrite H (high or low) data i toProgram memory page at wordaddress b. Data Low byte must beloaded before Data High byte isapplied within the same address.Write Program MemoryPage0100 11000000 aaaabbbx xxxxxxxx xxxxWrite Program memory Page ataddress a:b.Read EEPROM Memory1010 000000xx xxxabbbb bbbboooo ooooRead data o from EEPROMmemory at address a:b.Write EEPROM Memory1100 000000xx xxxabbbb bbbbiiii iiiiWrite data i to EEPROM memoryat address a:b.Read Lock Bits0101 10000000 0000xxxx xxxxxxoo ooooRead Lock Bits. “0” = programmed,“1” = unprogrammed.
See Table85 on page 219 for details.Write Lock Bits1010 1100111x xxxxxxxx xxxx11ii iiiiWrite Lock Bits. Set bits = “0” toprogram Lock Bits. See Table 85on page 219 for details.Read Signature Byte0011 000000xx xxxxxxxx xxbboooo ooooRead Signature Byte o at addressb.Write Fuse Bits1010 11001010 0000xxxx xxxxiiii iiiiSet bits = “0” to program, “1” tounprogram.
See Table 88 onpage 221 for details.Write Fuse High Bits1010 11001010 1000xxxx xxxxiiii iiiiSet bits = “0” to program, “1” tounprogram. See Table 87 onpage 220 for details.Read Fuse Bits0101 00000000 0000xxxx xxxxoooo ooooRead Fuse Bits. “0” = programmed,“1” = unprogrammed. See Table88 on page 221 for details.Read Fuse High Bits0101 10000000 1000xxxx xxxxoooo ooooRead Fuse high bits.
“0” = programmed, “1” = unprogrammed.See Table 87 on page 220 fordetails.Read Calibration Byte0011 100000xx xxxx0000 00bboooo ooooRead Calibration ByteNote:Operationa = address high bitsb = address low bitsH = 0 – Low byte, 1 – High byteo = data outi = data inx = don’t care2372486O–AVR–10/04SPI Serial ProgrammingCharacteristics238For characteristics of the SPI module, see “SPI Timing Characteristics” on page 243.ATmega8(L)2486O–AVR–10/04ATmega8(L)Electrical CharacteristicsNote:Typical values contained in this datasheet are based on simulations and characterization of other AVR microcontrollers manufactured on the same process technology. Min and Max values will be available after the device is characterized.Absolute Maximum Ratings*Operating Temperature.................................. -55°C to +125°C*NOTICE:Storage Temperature .....................................
-65°C to +150°CVoltage on any Pin except RESETwith respect to Ground ................................-0.5V to VCC+0.5VVoltage on RESET with respect to Ground......-0.5V to +13.0VStresses beyond those listed under “AbsoluteMaximum Ratings” may cause permanent damage to the device. This is a stress rating only andfunctional operation of the device at these orother conditions beyond those indicated in theoperational sections of this specification is notimplied. Exposure to absolute maximum ratingconditions for extended periods may affectdevice reliability.Maximum Operating Voltage ............................................
6.0VDC Current per I/O Pin ............................................... 40.0 mADC Current VCC and GND Pins................................ 200.0 mADC CharacteristicsTA = -40°C to 85°C, VCC = 2.7V to 5.5V (unless otherwise noted)SymbolParameterConditionMinTypMaxUnitsVCC(1)VVILInput Low VoltageExcept XTAL1 pin-0.50.2VIL1Input Low VoltageXTAL1 and RESET pins, Ext. Clock Selected-0.50.1 VCC(1)VVIHInput High VoltageExcept XTAL1 and RESET pins0.6 VCC(2)VCC + 0.5V0.8VCC(2)VCC + 0.5V0.9VCC(2)VCC + 0.5V0.70.5VVVIH1Input High VoltageXTAL1 pin, External Clock SelectedVIH2Input High VoltageRESET pinVOLOutput Low Voltage(3)(Ports A,B,C,D)IOL = 20 mA, VCC = 5VIOL = 10 mA, VCC = 3VVOHOutput High Voltage(4)(Ports A,B,C,D)IOH = -20 mA, VCC = 5VIOH = -10 mA, VCC = 3VIILInput LeakageCurrent I/O PinVcc = 5.5V, pin low(absolute value)1µAIIHInput LeakageCurrent I/O PinVcc = 5.5V, pin high(absolute value)1µARRSTReset Pull-up Resistor3080kΩRpuI/O Pin Pull-up Resistor2050kΩ4.22.2VV2392486O–AVR–10/04TA = -40°C to 85°C, VCC = 2.7V to 5.5V (unless otherwise noted) (Continued)SymbolParameterConditionMinTypMaxUnitsActive 4 MHz, VCC = 3V(ATmega8L)5mAActive 8 MHz, VCC = 5V(ATmega8)15mAIdle 4 MHz, VCC = 3V(ATmega8L)2mAIdle 8 MHz, VCC = 5V(ATmega8)7mAWDT enabled, VCC = 3V28µAWDT disabled, VCC = 3V3µA20mV50nAPower Supply CurrentICCPower-down mode(5)VACIOAnalog ComparatorInput Offset VoltageVCC = 5VVin = VCC/2IACLKAnalog ComparatorInput Leakage CurrentVCC = 5VVin = VCC/2tACIDAnalog ComparatorPropagation DelayVCC = 2.7VVCC = 4.0VNotes:240-50750500ns1.
“Max” means the highest value where the pin is guaranteed to be read as low2. “Min” means the lowest value where the pin is guaranteed to be read as high3. Although each I/O port can sink more than the test conditions (20mA at Vcc = 5V, 10mA at Vcc = 3V) under steady stateconditions (non-transient), the following must be observed:PDIP Package:1] The sum of all IOL, for all ports, should not exceed 400 mA.2] The sum of all IOL, for ports C0 - C5 should not exceed 200 mA.3] The sum of all IOL, for ports B0 - B7, C6, D0 - D7 and XTAL2, should not exceed 100 mA.TQFP and MLF Package:1] The sum of all IOL, for all ports, should not exceed 400 mA.2] The sum of all IOL, for ports C0 - C5, should not exceed 200 mA.3] The sum of all IOL, for ports C6, D0 - D4, should not exceed 300 mA.4] The sum of all IOL, for ports B0 - B7, D5 - D7, should not exceed 300 mA.If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greaterthan the listed test condition.4.














