I am not able to figure this when stepping through the code, as soon as the debugger processes status = USB0_ISTAT I get an unhandled interrupt. I can hover over the USB0_ISTAT and get the value of it but I am not able to do anything with it in code?
uint8_t status;
status = USB0_ISTAT;
I can also add USB0_ISTAT to the expression window and the value shows up without any issue.
Hello Brad,
USB0_ISTAT register should be read correctly only if USB clock gate was enabled before.
Remember that USB can be fed from USB_CLKIN or MCGFLLCLK/MCGPLLCLK/IRC48M (selected in SIM_SOPT2) but you need to enable clock gate control in SIM_SCGC4 register:
SIM_SCGC4 |= SIM_SCGC4_USBOTG_MASK;
Hope this helps!
Regards,
Isaac