UM10360 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2013. All rights reserved.
User manual Rev. 3 — 19 December 2013  245 of 841
NXP Semiconductors
UM10360
Chapter 11: LPC176x/5x USB device controller
11.12 Serial interface engine command description
The functions and registers of the Serial Interface Engine (SIE) are accessed using 
commands, which consist of a command code followed by optional data bytes (read or 
write action). The USBCmdCode (Table 220
) and USBCmdData (Table 221 ) registers are 
used for these accesses.
A complete access consists of two phases:
1. Command phase: the USBCmdCode register is written with the CMD_PHASE field 
set to the value 0x05 (Command), and the CMD_CODE field set to the desired 
command code. On completion of the command, the CCEMPTY bit of USBDevIntSt is 
set.
2. Data phase (optional): for writes, the USBCmdCode register is written with the 
CMD_PHASE field set to the value 0x01 (Write), and the CMD_WDATA field set with 
the desired write data. On completion of the write, the CCEMPTY bit of USBDevIntSt 
is set. For reads, USBCmdCode register is written with the CMD_PHASE field set to 
the value 0x02 (Read), and the CMD_CODE field set with command code the read 
corresponds to. On completion of the read, the CDFULL bit of USBDevInSt will be set, 
indicating the data is available for reading in the USBCmdData register. In the case of 
multi-byte registers, the least significant byte is accessed first.
An overview of the available commands is given in Table 241
.
Here is an example of the Read Current Frame Number command (reading 2 bytes):
USBDevIntClr = 0x30;           // Clear both CCEMPTY & CDFULL
USBCmdCode = 0x00F50500;       // CMD_CODE=0xF5, CMD_PHASE=0x05(Command)
while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.
USBDevIntClr = 0x10;           // Clear CCEMPTY interrupt bit.
USBCmdCode = 0x00F50200;       // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)
while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.
USBDevIntClr = 0x20;           // Clear CDFULL.
CurFrameNum = USBCmdData;      // Read Frame number LSB byte.
USBCmdCode = 0x00F50200;       // CMD_CODE=0xF5, CMD_PHASE=0x02(Read)
while (!(USBDevIntSt & 0x20)); // Wait for CDFULL.
Temp = USBCmdData;             // Read Frame number MSB byte
USBDevIntClr = 0x20;           // Clear CDFULL interrupt bit.
CurFrameNum = CurFrameNum | (Temp << 8);
Here is an example of the Set Address command (writing 1 byte):
USBDevIntClr = 0x10;           // Clear CCEMPTY.
USBCmdCode = 0x00D00500;       // CMD_CODE=0xD0, CMD_PHASE=0x05(Command)
while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.
USBDevIntClr = 0x10;           // Clear CCEMPTY.
USBCmdCode = 0x008A0100;       // CMD_WDATA=0x8A(DEV_EN=1, DEV_ADDR=0xA), 
                 // CMD_PHASE=0x01(Write)
while (!(USBDevIntSt & 0x10)); // Wait for CCEMPTY.
USBDevIntClr = 0x10;           // Clear CCEMPTY.