[200] USBD: Cannot write to SIZE.EPOUT register

This anomaly applies to IC Rev. Engineering A, build codes QIAA-AA0.

Symptoms

SIZE.EPOUT[n] registers are not writable.

Conditions

When a user tries to write SIZE.EPOUT[n] register to accept further OUT traffic ignoring current endpoint data and state.

Consequences

Cannot use SIZE.EPOUT[n] register write to allow traffic on the endpoint.

Workaround

  1. Trigger a dummy EasyDMA transfer on the endpoint (hard to make it 100% stable).
  2. Use the following code to clear EPOUTn:
    
    void epout_drop(uint8_t n)
    {
        *((volatile uint32_t *)(0x40027800)) = 0x7C5 + (2u * n);
        *((volatile uint32_t *)(0x40027804)) = 0;
        (void)(*((volatile uint32_t *)(0x40027804)));
    }
    
    The code should be executed from critical region to make sure that nothing interrupts the above registers access sequence.