beautypg.com

Texas Instruments MSC1210 User Manual

Page 261

background image

Serial Peripheral Interface (SPI)

17-33

Keil Simulator

data displayed in the SPICON window, on the basis of the bit position of the
corresponding configuration bit within the SFR bit pattern. Likewise, changing
the clock rate divide by value changes the SPICON entry accordingly. The re-
sult of the oscillator frequency divided by the selected divide by factor is dis-
played in the non-editable master clock window.

The trigger level for the transmit IRQ and receive IRQ are selectable through
the selection windows marked IRQ Level within the transmit buffer and receive
buffer blocks, respectively. The number of data bytes currently in the circular
FIFO buffer (waiting to be transmitted or already received and waiting to be
read) are displayed in the SPITCON and SPIRCON windows, respectively.

Clicking on the transmit flush buffer box, TXFLUSH, destroys the bytes of data
within the circular buffer that are waiting to be transmitted. It changes the SPI trans-
mit pointer so that it points to the same address as the FIFO OUT pointer, and
clears the transmit counter value within the SPITCON SFR. The transmit counter
indicates the number of bytes within the circular buffer that are waiting to be trans-
mitted. Similarly, clicking on the receive flush buffer RXFLUSH box, destroys the
bytes of data, within the circular buffer, that have already been received, but still
waiting to be read by the processor. It forces the receive pointer to point to the same
address location as the FIFO IN pointer, and it resets the receive counter value
within the SPIRCON SFR. The receive counter indicates the number of bytes with-
in the circular buffer that are waiting to be read by the processor.

It is worth stressing that all this window text editing and check box marking are
just alternative methods of programming the various SFRs in software.

The circular buffer can be set or redefined, by writing the desired value into the
editable transmit pointer window (SPISTART) and the editable receive buffer
window (SPIEND). You will observe that whatever entry is made into the SPIS-
TART text window also appears in the non-editable text window labeled Buffer
Start, and the editable text window labeled SPIEND. The content of the non-
editable text window labeled Buffer End remains unchanged. Writing the de-
sired value for the other end of the circular buffer causes the entered value to
appear in the Buffer End display window, but the data displayed in the SPIEND
window automatically reverts to the value written into the SPISTART window.
So, before data communication begins, SPISTART and SPIEND must contain
the same value, implying that the buffer is empty, whereas the Buffer Start and
Buffer End display the boundaries for the DMA circular buffer.
Although the contents of the SPISTART and SPIEND windows will change as
data is written into and transmitted out of the transmit buffer, and data is received
into and read from the receive buffer, the contents of the non-editable text win-
dows Buffer Start and Buffer End will not change. Notice that flushing the trans-
mit buffer will not affect the contents of the SPISTART window; it seems as
though the transmit data was never written into the buffer. Flushing the receive
buffer will neither affect the contents of the SPISTART window nor those of the
SPIEND window.

Data written into the editable text window SPIDATA will be handled as a piece
of data to be transmitted. The SPITCON and SPISTART windows will be prop-
erly updated, the circular buffer entry will be made into the appropriate buffer
address pointed to by the transmit pointer. The values in the SPITCON window