Why DRV_USBHS_PersistentInterruptSourceClear(SOURCEUSB1) isn't equal to IFS4bits.USBIF = 0
I'm working with the PIC32MZ2048EFM100 with Harmony 2.06 and XC32 v2.30.
I'm using the USB module to emulate an RS232 COM port.
I'm reviewing the interrupts related to the module to determine a problem.
The way to clean the USB interrupt is as follows:
The interrupt source is always INT_SOURCE_USB_1 (which is 0x00084)
Within the function _DRV_USBHS_PersistentInterruptSourceClear the following is done:
PLIB_TEMPLATE void INT_SourceFlagClear_Default( INT_MODULE_ID index , INT_SOURCE source )
volatile uint32_t *IFSx = (volatile uint32_t *) (&IFS0 + ((0x10 * (source / 32)) / 4));
volatile uint32_t *IFSxCLR = (volatile uint32_t *)(IFSx + 1);
*IFSxCLR = 1 << (source & 0x1f);
If source is equal to 0x0000084,the operation 1 << (source & 0x1f) is equal to 0x1000 and writing that number in IFS4CLR is equivalent to setting logical zero in bit 3 of IFS4.
If the above statement is correct, then it will not be cleaning the USBIF bit, but would clean the CMP2IF bit.
If the statement is incorrect and if the bit USBIF is being cleaned, because instead of writing the INT_SourceFlagClear_Default function, I simply clean (
IFS4bits.USBIF = 0;
) that flag, but the MCU restarts every moment and doesn't work properly (I guess it restarts because it never cleans the flag until the stack overflows)
Any comments or suggestions are welcome.