AnsweredAssumed Answered

USB Host interrupt not working after port

Question asked by Jason Baker on Feb 25, 2020
Latest reply on Feb 26, 2020 by Sabina Bruce

Hi,

 

I've recently begun to work on NXP products, and the next thing I'm trying to add to my project is USB Host MSD capabilities. 

 

I'm working with SDK 2.6.0 for FRDM-K66F. On the FRDM-K66 board I was able to get the demo frdmk66f_host_msd_fatfs_freertos to work. I then tested this demo project on the board I am working on, which is a MK66FN2M0VLQ18R.

 

I was able to successfully observe the expected test printouts on the MK66FN board. Then I tried to port the demo functionality to my project that has many other tasks and modules operating, and I'm unable to observe a USB host enumeration.

 

After troubleshooting it for a while I've learned and fixed a few things:

  •  the interrupt USBHS_IRQHandler which contains USB_HostEhciIsrFunction(g_HostHandle) never gets called (this interrupt runs constantly within the demo project.
  • The USB_HostTask runs as far as I can tell. It runs once and gets to USB_OsaEventWait, which looks like it's waiting for an event to be created as a result of the USBHS_IRQHandler interrupt detecting a port change.
  • The USB_HostApplicationTask runs correctly, but without the enumeration it doesn't have a device state or a run state.

 

Below is my attempts at determining the status of the ISR within the code related to the setup within USB_HostIsrEnable. I have striked through areas of the code that are not compiled as a result of a define not being present. (This is using a EHCI controller, not a KHCI for instance)

void USB_HostIsrEnable(void)
{
uint8_t irqNumber;
#if defined(USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U)
uint8_t usbHOSTEhciIrq[] = USBHS_IRQS;
irqNumber = usbHOSTEhciIrq[CONTROLLER_ID - kUSB_ControllerEhci0];
#endif /* USB_HOST_CONFIG_EHCI */
#if defined(USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI > 0U)
uint8_t usbHOSTKhciIrq[] = USB_IRQS;
irqNumber = usbHOSTKhciIrq[CONTROLLER_ID - kUSB_ControllerKhci0];
#endif /* USB_HOST_CONFIG_KHCI */

/* Install isr, set priority, and enable IRQ. */
#if defined(__GIC_PRIO_BITS)
GIC_SetPriority((IRQn_Type)irqNumber, USB_HOST_INTERRUPT_PRIORITY);
#else
NVIC_ClearPendingIRQ(irqNumber);
NVIC_SetPriority((IRQn_Type)irqNumber, USB_HOST_INTERRUPT_PRIORITY);
#endif
EnableIRQ((IRQn_Type)irqNumber);

uint32_t test_print = 0;
IRQn_Type usb_host_irq_num = USBHS_IRQn;
test_print = NVIC_GetEnableIRQ(usb_host_irq_num);
debug_print("USB Host Interrupt %s enabled. \n", test_print? "is" : "is not"); 

test_print = NVIC_GetPendingIRQ(usb_host_irq_num);
debug_print("USB Host Interrupt %s pending. \n", test_print? "is" : "is not");


}

The result of the print statements are "is enabled" "is not pending".

 

Major differences that I can think of that could cause it to work on the demo project but not after porting to my project:

The demo is strictly a C project, and the project I'm porting to is a mix of c++ and c.

The project has 20 tasks running, but to my knowledge the tasks shouldn't override interrupts.

This project also contains a usb device for communication, this is established via middleware and running on USB0.

 

I'd like to know possible reasons why the interrupt is not firing as it is in the demo. If anyone can help, I would appreciate it.

 

Thanks,

 

Jason

Outcomes