USB Host interrupt not working after port

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB Host interrupt not working after port

跳至解决方案
3,234 次查看
jbaker1
Contributor I

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

0 项奖励
回复
1 解答
3,111 次查看
jbaker1
Contributor I

It seems the Host Power was not configured correctly in my project, and after fixing this, the Interrupt triggers. 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
2,761 次查看
Microfelix
Contributor IV

Hello,
but the usb on the k66 together with other activities you work well?
I am making the same project, but often reading a file continuously from the USB, it goes into error and I have to extract and insert the key again to get it started again.

Did you notice anything strange?
Maurizio

0 项奖励
回复
3,112 次查看
jbaker1
Contributor I

It seems the Host Power was not configured correctly in my project, and after fixing this, the Interrupt triggers. 

0 项奖励
回复
3,111 次查看
Sabina_Bruce
NXP Employee
NXP Employee

Im glad you were able to resolve this and thank you for posting your answer. 

Best Regards,

Sabina

0 项奖励
回复