I am developing a device that must send out data through the FIFO at speeds up to 4 Mbit/s. I have implemented a bulk transfer as follows:
void TD_Poll(void) // Called repeatedly while the device is idle { if(OutOutPtr - OutInPtr > 64 | OutOutPtr < OutInPtr) { if(!(OUT2CS & 0x20)) { if(OUT2BC && DMAOK) { DMAOK = FALSE; OUTC = OUT2BC; DMALEN = OUT2BC; DMASRC = &OUT2BUF; DMADEST = &OutBuffer[OutInPtr]; DMAGO = 1; DMAOK = TRUE; OutInPtr += OUT2BC; if (OutInPtr >= 1024) OutInPtr = 0; OUT2BC = 0; } } } }