What do the EPXFIFOBCH and EPXFIFOBCL registers contain and how can they be used?
The EPXFIFOBCH and EPXFIFOBCL registers contain the number of bytes received from the interface domain. One way of using it is to commit a short packet, which is sent from the external master at the end of a long transfer. To do this, use the following code snippet in TD_Poll of the slave firmware:
if( (( EPXFIFOBCH<<8) | (EPXFIFOBCL)) < 0x200) //if the packet is short(here x is the IN endpoint which //receives data from external master)
EPXFIFOCFG = 0x00; //change from Auto mode to Manual mode
INPKTEND = 0x0X; //commit the short packet
EPXFIFOCFG = 0x0C; //back to Auto mode
Here, to commit the short packet the FIFO configuration is changed from Auto to Manual mode. Then, it is converted back to Auto mode if the master continues the long transfer.