I tried a simple test and the behavior of the PERI_TXCSR register does not seem to follow the spec.
I'm using address 0x8512 for non-indexed version of endpoint 1 register.
TXMAXP is set to 800 and the FIFO is configured for 2048 bytes (SZ = 7, DPB = 1) and ISOUPDATE bit is set in POWER register.
With no IN packets being requested from host.
I write a packet to the FIFO and set the TXPKTRDY bit in PERI_TXCSR
- this generates an unexpected interrupt on endpoint 1 and a readback of PERI_TXCSR shows FIFONOTEMPTY and TXPKTRDY bits both clear
- after some amount of time (less than 1ms but I didn't poll it to measure), FIFONOTEMPTY comes back set but TXPKTRDY bit still clear
I write a second packet to the FIFO (for double buffering)
- does not generate an interrupt
- after some amount of time both FIFONOTEMPTY and TXPKTRDY bits read as set (as expected)
At this point I try clearing the FIFO by FLUSHING but setting the FLUSH bit in PERI_TXCSR (twice at least, actually tried several times) seems to have no effect at all.
- both FIFONOTEMPTY and TXPKTRDY remain set even if written as zeros, no interrupts are generated
Starting a transfer from the host confirms (via bus analyzer) that the two packets written to the FIFO above are sent to the host.
So it seems that:
- When double buffering is enabled you get an interrupt the first time you set the TXPKTRDY bit (because TXPKTRDY was then cleared??)
- When double buffering is enabled you only see TXPKTRDY bit set when two packets have been written to the FIFO
- FLUSH bit appears to have no effect when 2 packets are in the FIFO
But if you set the FLUSH bit when only one packet is in the FIFO, and after the FIFONOTEMPTY bit reads 1 then you do get an interrupt and the FIFONOTEMPTY bit comes back as clear. Despite the fact that the spec says the FLUSH bit has no effect if the TXPKTRDY bit is clear.