12.07.2015 Views

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

ATmega32A Datasheet - Sunrom Technologies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ATmega32A</strong>Figure 20-18. Formats and States in the Slave Transmitter ModeReception of the ownslave address and one ormore data bytesS SLA R A DATA ADATAAP or S$A8 $B8$C0Arbitration lost as masterand addressed as slaveA$B0Last data byte transmitted.Switched to not addressedslave (TWEA = '0')AAll 1'sP or S$C8From master to slaveDATAAAny number of data bytesand their associated acknowledge bitsFrom slave to masternThis number (contained in TWSR) correspondsto a defined state of the Two-wire Serial Bus. Theprescaler bits are zero or masked to zero20.7.5 Miscellaneous StatesThere are two status codes that do not correspond to a defined TWI state, see Table 20-6.Status $F8 indicates that no relevant information is available because the TWINT Flag is not set.This occurs between other states, and when the TWI is not involved in a serial transfer.Status $00 indicates that a bus error has occurred during a Two-wire Serial Bus transfer. A buserror occurs when a START or STOP condition occurs at an illegal position in the format frame.Examples of such illegal positions are during the serial transfer of an address byte, a data byte,or an acknowledge bit. When a bus error occurs, TWINT is set. To recover from a bus error, theTWSTO Flag must set and TWINT must be cleared by writing a logic one to it. This causes theTWI to enter the not addressed slave mode and to clear the TWSTO Flag (no other bits inTWCR are affected). The SDA and SCL lines are released, and no STOP condition istransmitted.Table 20-6.Status Code(TWSR)Prescaler Bitsare 0Miscellaneous StatesStatus of the Two-wire SerialBus and Two-wire Serial InterfaceHardware$F8 No relevant state informationavailable; TWINT = “0”$00 Bus error due to an illegalSTART or STOP conditionTo/from TWDRApplication Software ResponseTo TWCRSTA STO TWINT TWEANext Action Taken by TWI HardwareNo TWDR action No TWCR action Wait or proceed current transferNo TWDR action 0 1 1 X Only the internal hardware is affected, no STOP conditionis sent on the bus. In all cases, the bus is releasedand TWSTO is cleared.20.7.6 Combining Several TWI ModesIn some cases, several TWI modes must be combined in order to complete the desired action.Consider for example reading data from a serial EEPROM. Typically, such a transfer involvesthe following steps:1. The transfer must be initiated2. The EEPROM must be instructed what location should be read3. The reading must be performed8155C–AVR–02/11200

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!