Trying to run USB OTG in MSC Host mode. Slightly adapted this project under the MK STM32F105 and fixed some errors. Laid out the main part of the revised project here . But now the program stops in an infinite loop in the stm32_ub_usb_msc_host.c file:

USB_MSC_HOST_STATUS_t UB_USB_MSC_HOST_Do(void) { if(USB_MSC_HOST_STATUS!=USB_MSC_DEV_NOT_SUPPORTED) { // когда флешка USB не поддерживается, // функция не будет вызываться USBH_Process(&USB_OTG_Core, &USB_Host); } return(USB_MSC_HOST_STATUS); } 

In the USBH_Process () function, the program expects an interrupt on the OTG_FS_IRQHandler vector. To then translate the state of the variable USB_MSC_HOST_STATUS to USB_MSC_DEV_CONNECTED . But interruption does not occur. I would also like to clarify that an interrupt is expected in case HOST_IDLE:

 void USBH_Process(USB_OTG_CORE_HANDLE *pdev , USBH_HOST *phost) { volatile USBH_Status status = USBH_FAIL; switch (phost->gState) { case HOST_ISSUE_CORE_RESET : if ( HCD_ResetPort(pdev) == 0) { phost->gState = HOST_IDLE; } break; case HOST_IDLE : if (HCD_IsDeviceConnected(pdev)) { /* Wait for USB Connect Interrupt void USBH_ISR_Connected(void) */ USBH_DeAllocate_AllChannel(pdev); phost->gState = HOST_DEV_ATTACHED; } break; ... 

If the OTG_FS_IRQHandler interrupt occurs, then host.ConnSts is assigned 1. And then the program will go into case HOST_DEV_ATTACHED . But not yet. Interrupt initialized:

 void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) { NVIC_InitTypeDef NVIC_InitStructure; /* Enable USB Interrupt */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } 

USB bus stashed:

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE); 

What could be the reason for the absence of a transition to an interrupt?

  • The problem was resolved. It was in the wiring diagram. DM and DP were powered up. I removed these braces and the flash drive was missing, now I need to cope with mounting / unmounting and writing a file. - Anton Kiryukhin

0