Other Parts Discussed in Thread: EK-TM4C1294XL, , TPD4S012, EK-TM4C123GXL
Tool/software: Code Composer Studio
Hello Everyone,
I am having trouble on the msc application on my custom pcb. I first developed an application to read data from a flash stick with the fat file system and ran it on ek-tm4c1294xl development kit.
Now I am trying to port the same application to the tm4c123fh6pm chip I am using.
The following differences are present on my pcb.
The processor runs without a crystal from the internal oscillator with pll at 80 mhz.
There is a Power-Distribution Switch present to monitor VBUS. This chip has an active low enable connected to EPEN signal from the chip.
Instead of TPD4S012, the design has USBLC6-2 for ESD protection.
There is USB-A and Micro-USB ports present on the design (they are connected to the same DP, DM, VBUS and GND lines) but only 1 device is plugged in, I just needed to test both for functionality but only 1 will remain in the final design.
The changes I made are following:
TM4C129 configuration:
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xff; ROM_GPIOPinConfigure(GPIO_PD6_USB0EPEN); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_GPIOPinTypeUSBDigital(GPIO_PORTD_BASE, GPIO_PIN_6); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7); ROM_GPIOPinTypeGPIOInput(GPIO_PORTQ_BASE, GPIO_PIN_4); // // Initialize the USB stack mode and pass in a mode callback. // USBStackModeSet(0, eUSBModeHost, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers); // // Open an instance of the mass storage class driver. // g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the power configuration. This sets the power enable signal // to be active high and does not enable the power fault. // USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER); // // Tell the USB library the CPU clock and the PLL frequency. This is a // new requirement for TM4C129 devices. // SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate); USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock); USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); // // Initialize the USB controller for host operation. // USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE); // // Initialize the file system. // f_mount(0, &g_sFatFs);
TM4C123 Configuration:
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0xff; ROM_GPIOPinConfigure(GPIO_PD2_USB0EPEN); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5); ROM_GPIOPinTypeUSBDigital(GPIO_PORTD_BASE, GPIO_PIN_2); ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the USB stack mode and pass in a mode callback. // USBStackModeSet(0, eUSBModeHost, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers); // // Open an instance of the mass storage class driver. // g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the power configuration. This sets the power enable signal // to be active low and does not enable the power fault. // USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_LOW | USBHCD_VBUS_FILTER); SysCtlUSBPLLEnable(); // // Initialize the USB controller for host operation. // USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE); // // Initialize the file system. // f_mount(0, &g_sFatFs);
The following changes have been made to port the code:
The clock configuration has been changed where applicable. (Systick etc.)
Instead of Feature Set and SysCtlVCOGet Calls for PLL SysCtlUSBPLLEnable call have been made.
Since system clock is 80 MHz USBHCDFeatureSet call for CPUCLK was omitted but I also tried the code by including it and passing the system value with a pointer but it didn't make any difference.
The startup file has the necessary interrupt handler functions.
The pins have been changed.
The rom defines were changed.
USBHCDPowerConfigInit was changed to accomodate EPEN as active low.
I verify that VBUS is 5V and EPEN is low when the configuration is finished. ID also is low and device is connected to the Micro-USB slot.
The MSC Example was using the OTG Interrupt Handler and that is also what I configured it with. The OTG Interrupt never fires when a device is plugged in.
I make the necessary SysTick configuration and the interrupt handler is also in the vector table and firing.
I also tried eUSBModeForceHost but that also didn't work. It works on the TM4C129 dev board.
I am trying to find out what I missed while porting the code or If I am making a fundamental mistake.
I looked at USB Host MSC example from DK TM4C123 Board and that was actually using HCD Host instead of OTG on the function calls but If the interrupt is fired to detect the device OTG Main function also calls HCD Main function for detected devices. I didn't notice any major differences besides this.
EDIT: I also tried just jumping DP and DM pins to the TM4C129 device and supplying the power from TM4C123 device for VBUS with the correct EPEN. It works that way which leads me to believe my circuit is good but there is something on the configuration which is causing the problem.
Thanks,
Tuna