atmega323l ATMEL Corporation, atmega323l Datasheet - Page 115

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
Assembly Code Example –
Master Receiver Mode
1457G–AVR–09/03
Figure 56. Formats and States in the Master Receiver Mode
Successfull
Reception
from a Slave
Receiver
Next Transfer
Started with a
Repeated Start
Condition
Not Acknowledge
Received after the
Slave Address
Arbitration Lost in Slave
Address or Data Byte
Arbitration Lost and
Addressed as Slave
;Part specific include file and TWI include file must be included.
; <Initialize registers TWAR and TWBR>
wait5:in
wait6:in
From Master to Slave
From Slave to Master
$08
S
ldi
sbrs r16, TWINT
rjmp wait5
in
cpi
brne ERROR
ldi
out
ldi
out
sbrs r16, TWINT
rjmp wait6
out
SLA
r16, (1<<TWINT) | (1<<TWSTA) | (1<<TWEN)
r16,TWCR
r16, TWSR
r16, START
r16, 0xc9
TWDR, r16
r16, (1<<TWINT) | (1<<TWEN)
TWCR, r16
r16,TWCR
R
TWCR, r16
MR
A or A
DATA
$40
$48
$38
$68
A
A
A
$78
Other Master
Other Master
n
Continues
Continues
P
;Send START condition
; Wait for TWINT Flag set. This indicates that
; the START condition has been transmitted
; Check value of TWI Status Register. If status
; different from START, go to ERROR
; Load SLA+R into TWDR Register
; Clear TWINT bit in TWCR to start transmission
; of SLA+R
; Wait for TWINT Flag set. This indicates that
; SLA+R has been transmitted, and ACK/NACK has
; been received
$B0
DATA
A
Any Number of Data Bytes
and their Associated Acknowledge Bits
This Number (Contained in TWSR) Corresponds
to a Defined State of the Two-wire Serial Bus
$50
$38
To Corresponding
States in Slave Mode
A
A
Other Master
DATA
Continues
ATmega323(L)
$58
A
$10
P
S
SLA
W
R
115
MT

Related parts for atmega323l