mg84fl54b Megawin Technology, mg84fl54b Datasheet - Page 58

no-image

mg84fl54b

Manufacturer Part Number
mg84fl54b
Description
Full-speed Usb Micro-controller
Manufacturer
Megawin Technology
Datasheet
17.4. Using the TWSI
The TWSI is byte-oriented and interrupt based. Interrupts are issued after all bus events, like reception of a byte
or transmission of a START condition. Because the TWSI is interrupt-based, the application software is free to
carry on other operations during a TWSI byte transfer. Note that the TWSI interrupt enable bit ETWSI bit
(AUXIE.6) together with the EA bit allow the application to decide whether or not assertion of the SI Flag should
generate an interrupt request. When the SI flag is asserted, the TWSI has finished an operation and awaits
application response. In this case, the status register SISTA contains a status code indicating the current state
of the TWSI bus. The application software can then decide how the TWSI should behave in the next TWSI bus
operation by properly programming the STA, STO and AA bits (in SICON).
The following operating flow charts will instruct the user to use the TWSI using state-by-state operation. First,
the user should fill SIADR with its own Slave address (refer to the previous description about SIADR). To act as
a master, after initializing the SICON, the first step is to set “STA” bit to generate a START condition to the bus.
To act as a slave, after initializing the SICON, the TWSI waits until it is addressed. And then follow the operating
flow chart for a number a next actions by properly programming (STA,STO,SI,AA) in the SICON. Since the
TWSI hardware will take next action when SI is just cleared, it is recommended to program (STA,STO,SI,AA) by
two steps, first STA, STO and AA, then clear SI bit (may use instruction “CLR SI”) for safe operation.
The figure below shows how to read the flow charts.
58
SLA+W will be transmitted;
ACK bit will be received.
(STA,STO,SI,AA)=(0,0,0,X)
08H
A START has been
Set STA to generate
a START.
transmitted.
.
.
.
The status code in SISTA, it is the current bus state.
The bus operation the TWSI has just finished.
Setting for the next bus operation. "x" means "don't care"
The expected next bus operation.
MG84FL54B Data Sheet
MEGAWIN

Related parts for mg84fl54b