Microchip Technology GPIODM-KPLCD Data Sheet

Page of 438
PIC18F2455/2550/4455/4550
DS39632E-page 194
 
© 2009 Microchip Technology Inc.
18.2
Setup for USB Control
When the SPP is configured for USB operation, data
can be clocked directly to and from the USB peripheral
without intervention of the microcontroller; thus, no
process time is required. Data is clocked into or out
from the SPP with endpoint (address) information first,
followed by one or more bytes of data, as shown in
Figure 18-5. This is ideal for applications that require
isochronous, large volume data movement. 
The following steps are required to set up the SPP for
USB control:
1.
Configure the SPP as desired, including wait
states and clocks.
2.
Set the SPPOWN bit for USB ownership.
3.
Set the buffer descriptor starting address
(BDnADRL:BDnADRH) to FFFFh.
4.
Set the KEN bit (BDnSTAT<5>) so the buffer
descriptor is kept indefinitely by the SIE. 
5.
Set the INCDIS bit (BDnSTAT<4>) to disable
automatic buffer address increment.
6.
Set the SPPEN bit to enable the module.
18.3
Setup for Microcontroller Control
The SPP can also act as a parallel port for the
microcontroller. In this mode, the SPPEPS register
(Register 18-3) provides status and address write
control. Data is written to and read from the SPPDATA
register. When the SPP is owned by the
microcontroller, the SPP clock is driven by the
instruction clock (F
OSC
/4).
The following steps are required to set up the SPP for
microcontroller operation:
1.
Configure the SPP as desired, including wait
states and clocks.
2.
Clear the SPPOWN bit.
3.
Set SPPEN to enable the module.
18.3.1
SPP INTERRUPTS
When owned by the microcontroller core, control can
generate an interrupt to notify the application when
each read and write operation is completed. The
interrupt flag bit is SPPIF (PIR1<7>) and is enabled by
the SPPIE bit (PIE1<7>). Like all other microcontroller
level interrupts, it can be set to a low or high priority.
This is done with the SPPIP bit (IPR1<7>).
18.3.2
WRITING TO THE SPP
Once configured, writing to the SPP is performed by
writing to the SPPEPS and SPPDATA registers. If the
SPP is configured to clock out endpoint address infor-
mation with the data, writing to the SPPEPS register
initiates the address write cycle. Otherwise, the write is
started by writing the data to the SPPDATA register.
The SPPBUSY bit indicates the status of the address
and the data write cycles. 
The following is an example write sequence:
1.
Write the 4-bit address to the SPPEPS register.
The SPP automatically starts writing the
address. If address write is not used, then skip
to step 3.
2.
Monitor the SPPBUSY bit to determine when the
address has been sent. The duration depends
on the wait states.
3.
Write the data to the SPPDATA register. The
SPP automatically starts writing the data.
4.
Monitor the SPPBUSY bit to determine when the
data has been sent. The duration depends on
the wait states.
5.
Go back to steps 1 or 3 to write a new address
or data.
FIGURE 18-5:
TRANSFER OF DATA BETWEEN USB SIE AND SPP
Note:
If a USB endpoint is configured to use the
SPP, the data transfer type of that
endpoint must be isochronous only.
Note:
The SPPBUSY bit should be polled to
make certain that successive writes to the
SPPEPS or SPPDATA registers do not
overrun the wait time due to the wait state
setting.
Byte 0
Byte 1
Byte 2
Byte 3
Byte n
Endpoint
Address
Write USB endpoint number to SPP 
Write outbound USB data to SPP or
read inbound USB data from SPP