Electronic – Several names for same/similar registers in PIC32MZ USB peripheral

pic

I am working on my first PIC-project for which I am utilizing a PIC32MZ2048EFH064. Right now I am struggling with some registers of the USB peripheral that are named differently in the datasheet than in the debugger.

For example, according to the datasheet, the USB endpoint 0 is configured by the registers USBIE0CSR0, USBIE0CSR2, and USBIE0CSR3. However, in some code examples in this forum the registers USBE0CSR0, USBE0CSR2, and USBE0CSR3 are used. These are also the only registers accessible by the debugger. In the datasheet (p. 213) it is written that both sets of registers are indexed by the same bits (see screenshot).

Screenshot from the datasheet p. 213

However, the registers contents differ (see additional screenshots from the datasheet (p. 225) and the debugger) which confuses me. The register USBIE0CSR0 is not available in the debugger at all.

Screenshot from the datasheet p. 225
Screenshot from the debugger

Can anybody explain why there are these two sets of registers and tell me which to use?

Thank you!

Best Answer

It's probably too late to be of any use but all the USBIENxxxx registers are related to whichever endpoint is pointed to by USBCSR3bits.ENDPOINT. So if you set ENDPOINT to 1 and then access USBIENCSR0bits you're actually accessing USBE1CSR0. The reason they may look different is if ENDPOINT is 0 it points to endpoint 0 and the registers for endpoint 0 look different from all the other endpoints.

It's very confusing and I don't know why they did it like this. The documentation is pretty poor!