LPC54605J256BD100 Won't attach USB clock Hi, my custom board will not attach the clock. I have been trying for weeks to get this to work. I cannot. I cannot find any results anywhere online, which will tell me how to successfully attach the USB1 clock. Surely there must be a logical set of instructions which will attach it properly, somewhere? All the config tools are set correctly with the correct frequencies and selections for it to work properly, but it does not. Several manual steps have been undertaken in main, in order to try to fix the obvious shortcomings of the gui tool. This has not helped. Probably the order and timing is incorrect. As there are so many, and the order is very particular, I am not surprised if it is very incorrect. Please, can somebody tell me where I am going wrong with the set up? I want to have USB working on this device. This is beyond frustrating at this point. Thanks. Main - int main(void) { vPortDefineHeapRegions(xHeapRegions); BOARD_InitBootPins(); BOARD_InitBootClocks(); BOARD_InitBootPeripherals(); BOARD_InitUSB1HS_USBPLL_Only(); SEGGER_RTT_Init(); PRINTF("System Booting...\r\n"); PRINTF("Core clock = %lu Hz\r\n", CLOCK_GetFreq(kCLOCK_CoreSysClk)); /* 1. POWER DOMAINS FIRST */ POWER_DisablePD(kPDRUNCFG_PD_VD2_ANA); POWER_DisablePD(kPDRUNCFG_PD_VD3); POWER_DisablePD(kPDRUNCFG_PD_VD5); POWER_DisablePD(kPDRUNCFG_PD_USB_PLL); POWER_DisablePD(kPDRUNCFG_PD_USB1_PHY); /* Power up the PHY LDO (Bit 24) which is often separate from the PHY logic */ SYSCON->PDRUNCFGCLR[0] = (1U << 24); SDK_DelayAtLeastUs(15000, SystemCoreClock); while (!(SYSCON->USBPLLSTAT & 0x1)); // Wait for hardware lock /* 2. THE MANUAL CLOCK FIX */ PRINTF("Applying Manual Clock Fix...\r\n"); // IMPORTANT: Ensure AHB clock is OFF so the divider logic is 'unloaded' SYSCON->AHBCLKCTRLCLR[2] = (1U << 18); SYSCON->USB1CLKDIV |= (1U << 30); // Halt divider SYSCON->USB1CLKSEL = 7U; // "Disable" (Park at None) for (volatile int i = 0; i < 1500; i++) { __asm("NOP"); } SYSCON->USB1CLKSEL = 2U; // Target: USBPLL (288MHz) SYSCON->USB1CLKDIV = (1U << 30) | 5U; // Target: Div by 6 (48MHz) for (volatile int i = 0; i < 1500; i++) { __asm("NOP"); } SYSCON->USB1CLKDIV &= ~(1U << 30); // Release Halt PRINTF("POST-FIX USB1CLKSEL: 0x%08lX\r\n", SYSCON->USB1CLKSEL); PRINTF("POST-FIX USB1CLKDIV: 0x%08lX\r\n", SYSCON->USB1CLKDIV); /* 3. HARDWARE ENABLE & RESET PULSE */ // Now that the clock is stable, turn on the AHB interface SYSCON->AHBCLKCTRLSET[2] = (1U << 18); //Pulse Reset to sync the controller to the 48MHz clock SYSCON->PRESETCTRLSET[2] = (1U << 18); for (volatile int i = 0; i < 1000; i++) { __asm("NOP"); } SYSCON->PRESETCTRLCLR[2] = (1U << 18); /* 5. FINAL DIAGNOSTICS BEFORE INIT */ PRINTF("\r\n--- PRE-INIT DIAGNOSTICS ---\r\n"); PRINTF("USB1CLKSEL : 0x%08lX\r\n", SYSCON->USB1CLKSEL); PRINTF("USB1CLKDIV : 0x%08lX\r\n", SYSCON->USB1CLKDIV); PRINTF("USBHSH->PORTSC1 : 0x%08lX\r\n", USBHSH->PORTSC1); PRINTF("PDRUNCFG : 0x%08lX\r\n", SYSCON->PDRUNCFG); /* --- 1. FORCE PHY CONFIG --- */ // 16: Host Mode, 17: Clock Valid, 21: Force VBUS, 23: Force 48MHz Lock USBHSH->PORTMODE |= (1U << 16) | (1U << 17) | (1U << 21) | (1U << 23); /* --- 2. FINAL HARDWARE RESET PULSE --- */ SYSCON->PRESETCTRLSET[2] = (1U << 18); for (volatile int i = 0; i < 5000; i++) { __asm("NOP"); } SYSCON->PRESETCTRLCLR[2] = (1U << 18); /* --- 3. STABILIZATION DELAY --- */ SDK_DelayAtLeastUs(10000, SystemCoreClock); /* --- 4. PRE-INIT DIAGNOSTICS --- */ PRINTF("\r\n--- FINAL HW CHECK ---\r\n"); PRINTF("USBHSH->USBSTS: 0x%08lX\r\n", USBHSH->USBSTS); PRINTF("USBHSH->USBCMD: 0x%08lX\r\n", USBHSH->USBCMD); PRINTF("USBHSH->PORTMODE: 0x%08lX\r\n", USBHSH->PORTMODE); /* 2. Re-sync the clock tree variables */ SystemCoreClockUpdate(); /* 3. Manually toggle the USB1 Clock Gate */ // SYSCON->AHBCLKCTRLSET[2] = (1U << 18); // Ensure AHB is on status_t clkStatus = CLOCK_EnableUsbhs0HostClock(kCLOCK_UsbSrcUsbPll, 48000000U); PRINTF("Clock enable returned: %d\r\n", clkStatus); PRINTF("USB PLL freq = %lu Hz\r\n", CLOCK_GetFreq(kCLOCK_UsbPll)); PRINTF("USB1CLK freq = %lu Hz\r\n", CLOCK_GetFreq(kCLOCK_UsbClk)); /* 6. STACK INIT */ usb_status_t status = USB_HostInit(CONTROLLER_ID, &g_HostHandle, USB_HostEvent); if (status != kStatus_USB_Success) { PRINTF("USB_HostInit failed with status %d\r\n", status); }
記事全体を表示