[SOLVED]
The problem has been solved by CLEARING the whole STAT byte of the endpoint0 (in and out) buffer descriptors BEFORE configure the buffer descriptor.
The ordering is like this (in bus reset interrupt handling):
RSTIF ?
- Clear UIR and UEIR
- UEP0 configure
- Clear TRNIF queue (by looping like: while( URI.TRNIF ){ UIR.TRNIF = 0; } )
- Clear PKTDIS
- Clear EP0_BD_OUT.STAT ( = 0x00 )
- Clear EP0_BD_INT.STAT ( = 0x00 )
- Configure EP0_BD_OUT.ADDR
- Configure EP0_BD_OUT.CNT
- Configure EP0_BD_OUT.STAT ( =0x88 ) [ give the BD to the SIE ]