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:
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
解決済! 解決策の投稿を見る。
It seems the Host Power was not configured correctly in my project, and after fixing this, the Interrupt triggers.
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
It seems the Host Power was not configured correctly in my project, and after fixing this, the Interrupt triggers.
Im glad you were able to resolve this and thank you for posting your answer.
Best Regards,
Sabina