atmega323l ATMEL Corporation, atmega323l Datasheet - Page 116

no-image

atmega323l

Manufacturer Part Number
atmega323l
Description
Atmega323 8-bit Avr Microcontroller With 32k Bytes Of In-system Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
116
ATmega323(L)
wait7:in
wait8:in
wait9:in
;<Receive more data bytes if needed>
;receive next to last data byte.
in
cpi
brne ERROR
ldi
out
sbrs r16, TWINT
rjmp wait7
in
cpi
brne ERROR
in
nop
ldi
out
sbrs r16, TWINT
rjmp wait8
in
cpi
brne ERROR
in
nop
ldi
out
sbrs r16, TWINT
rjmp wait9
in
cpi
brne ERROR
r16, TWSR
r16, MR_SLA_ACK
r16, (1<<TWINT) | (1<<TWEA) | (1<<TWEN)
TWCR, r16
r16,TWCR
r16, TWSR
r16, MR_DATA_ACK
r16, TWDR
r16, (1<<TWINT) | (1<<TWEA) | (1<<TWEN)
TWCR, r16
r16,TWCR
r16, TWSR
r16, MR_DATA_ACK
r16, TWDR
r16, (1<<TWINT) | (1<<TWEN)
TWCR, r16
r16,TWCR
r16, TWSR
r16, MR_DATA_NACK
; Check value of TWI Status Register. If status
; different from MR_SLA_ACK, go to ERROR
; Clear TWINT bit in TWCR to start reception of
; data. Setting TWEA causes ACK to be returned
; after reception of data byte
; Wait for TWINT Flag set. This indicates that
; data has been received and ACK returned
; Check value of TWI Status Register. If status
; different from MR_DATA_ACK, go to ERROR
; Input received data from TWDR.
;<do something with received data>
; Clear TWINT bit in TWCR to start reception of
; data. Setting TWEA causes ACK to be returned
;after reception of data byte
; Wait for TWINT Flag set. This indicates that
; data has been received and ACK returned
; Check value of TWI Status Register. If status
; different from MR_DATA_ACK, go to ERROR
; Input received data from TWDR.
;<do something with received data>
; Clear TWINT bit in TWCR to start reception of
; data. Not setting TWEA causes NACK to be
; returned after reception of next data byte
; receive last data byte. Signal this to Slave
; by returning NACK
; Wait for TWINT Flag set. This indicates that
; data has been received and NACK returned
; Check value of TWI Status Register. If status
; different from MR_DATA_NACK, go to ERROR
1457G–AVR–09/03

Related parts for atmega323l