Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
USBHostMSD - Add device failed - Freescale K22F with F401RE-USBHost
I try to read/write USB flash disk on FRDM-K22F, the implement source is USBHostMSD in F401RE-USBHost.
I got the error message: [USB_ERR: libs/USBHostMSD/USBHost/USBHost.cpp:56]ADD DEVICE FAILD parent:0 port:0 speed:full VID:9d9f PID:0000 class:e8 addr:1
The return error place is at line 53 in USBHost::addDevice(USBDeviceConnected* parent, int port, bool lowSpeed) of USBHost.cpp:
USBHost.cpp
int rc = controlRead(dev, 0x80, GET_DESCRIPTOR, 1<<8, 0, desc, 8); USB_TEST_ASSERT(rc == USB_TYPE_OK); if (rc != USB_TYPE_OK) { USB_ERR("ADD DEVICE FAILD"); }
The add device step is at line 132 in USBHALHost::init() of USBHALHost_KL46Z.cpp
USBHALHost_KL46Z.cpp
// Disable IRQ NVIC_DisableIRQ(USB0_IRQn); #if defined(TARGET_K64F) MPU->CESR=0; #endif // choose usb src as PLL SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK); // enable OTG clock SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK; // USB Module Configuration // Reset USB Module USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK; while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK); // Clear interrupt flag USB0->ISTAT = 0xff; // Set BDT Base Register USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8); USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16); USB0->BDTPAGE3=(uint8_t)((uint32_t)bdt>>24); // Set SOF threshold USB0->SOFTHLD = USB_SOFTHLD_CNT(1); // pulldown D+ and D-, enabled USB0->USBCTRL = USB_USBCTRL_PDE_MASK; USB0->USBTRC0 |= 0x40; // Host mode USB0->CTL |= USB_CTL_HOSTMODEEN_MASK; // Desable SOF packet generation USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK; NVIC_SetVector(USB0_IRQn, (uint32_t)_usbisr); NVIC_EnableIRQ(USB0_IRQn); bool lowSpeed = wait_attach(); for(int retry = 2; retry > 0; retry--) { // Enable RESET USB0->CTL |= USB_CTL_RESET_MASK; wait_ms(500); USB0->CTL &= ~USB_CTL_RESET_MASK; // Enable SOF USB0->CTL |= USB_CTL_USBENSOFEN_MASK; wait_ms(100); // token transfer initialize token_transfer_init(); USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK| USB_INTEN_ERROREN_MASK; USB0->ERREN |= USB_ERREN_PIDERREN_MASK| USB_ERREN_CRC5EOFEN_MASK| USB_ERREN_CRC16EN_MASK| USB_ERREN_DFN8EN_MASK| USB_ERREN_BTOERREN_MASK| USB_ERREN_DMAERREN_MASK| USB_ERREN_BTSERREN_MASK; if (addDevice(NULL, 0, lowSpeed)) { break; }
Am I missed any steps? or How can I do further test on the board?
Any advices would be appreciate. Thanks!