beautypg.com

Panasonic MN101C00 User Manual

Page 111

background image

Chapter 5 Serial Functions

97

■ Reception

(1)

Select the synchronous serial interface by setting the SC0CMD flag of the

serial interface 0 control register (SC0CTR) to "0."

(2)

Select the transfer bit count with the SC0LNG2 to 0 flags of the serial

interface 0 mode register 0 (SC0MD0). The transfer bit count can be set as

1 to 8 bits.

(3)

Specify whether the start condition is enabled or disabled with the SC0STE

flag of the SC0MD0 register.

(4)

Specify the first bit to be transferred (MSB first or LSB first) with the

SC0DIR flag of the SC0MD0 register.

(5)

Select the valid edge of the clock signal with the SC0CE1 to 0 flags of the

SC0MD0 register.

(6)

When the clock source is an internal clock:

Select the clock source with the SC0CK1 to 0 flags of serial interface 0

mode register 1 (SC0MD1).

Set the SC0CKM flag of the SC0MD1 register to specify whether or not

the clock source frequency will be divided by 8.

Select serial clock pin operation by setting the SC0SBTS flag of the

serial interface 0 mode register 3 (SC0MD3) to "1."

Set the SC0SBTM flag of the SC0MD3 register.

Set bit 2 of the port 0 direction control register (P0DIR) to the output

mode (P02/SBT0 output mode).

If necessary, set bit 2 of the port 0 pull-up resistor control register

(P0PLU) to add the pull-up resistor.

When the clock source is an external clock (SBT0 pin input):

Set bit 2 of the P0DIR register to the input mode.

If necessary, set bit 2 of the P0PLU register.

(7)

Select the SC0IOM flag of the SC0MD3 register.

(8)

Select serial communication by setting the SC0SBIS flag of the SC0MD3

register to "1." (Reception data wait.)

(9)

When the serial reception begins, the SC0BSY flag of the serial interface 0

control register (SC0CTR) is set to "1," indicating that a serial transfer is in

progress.

(10)

When the serial reception is complete, the SC0BSY flag of the SC0CTR

register is cleared to "0" and the SC0 transfer complete interrupt request flag

is set to "1." The SC0TRI flag of the SC0MD1 register is set to "1."

Synchronous Serial Interface

When the serial port is enabled

and the SC0CE1 to 0 flags of

the SC0MD0 register are

changed, the transfer bit count

in the SC0LNG2 to 0 flags of

the SC0MD0 register may by

incremented.

[

Section 5-2-3, "Serial

Interface Transfer Timing"]

If the start condition is enabled,

the SC0LNG2 to 0 flags of the

SC0MD0 register will be

cleared when the start

condition is received. In this

case, the receive bit count is

fixed at 8 bits.

The SC0SBTS flag of the

SC0MD3 register must be set

to "1" before setting the

SC0SBIS flag of the SC0MD3

register to "1."

If the internal clock is selected

as the clock source, after

setting the SC0SBIS flag of the

SC0MD3 register to "1," write

dummy data to the SC0TRB

register. If there is to be

another reception, write

dummy data again to the

SC0TRB register.

The SC0LNG2 to 0 flags

change at the opposite edge of

the transmit data output edge.

Serial interface 0 begins

operation when the SC0SBOS

flag or the SC0SBIS flag is set

to "1." Set the SC0SBOS flag

or the SC0SBIS flag after all

conditions have been set.

After the transfer is complete, the transfer bit count in the

SC0LNG2 to 0 flags of the SC0MD0 register will be

changed. Except in an 8-bit transfer count, reset the

transfer bit count at the time of the next reception.

When switching from reception to transmission, set the

SC0SBIS flag of the SC0MD3 register to "0" and then set

the SC0SBOS flag to "1." Do not change both of these

flags at the same time.