This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Host USB on tm4C123GH6PM seam to create some problem with the debugger

Other Parts Discussed in Thread: TM4C123GH6PM, CODECOMPOSER

Hi, 

I'm Jonny and this is the first time that i try to open a POST;

I'm trying to configure  a TM4C123GH6PM microcontroller like an host device in order to have the possibility to connect a pen drive.

i'm using an example i found for the tm4c123g CAN+USB development board to configure my microcontroller; I have configure everything in the property of the project to use it for my device ( or better i hope there is no strange setting that i completely forget to set ).

When i try do debug it i found a strange error when i reach a precise point of the program; in the following i will try to give you some piece of my code and the exact point where i have the problem 

CONFIGURATION OF THE USB ( BASICALLY I COPY IT FROM THE EXAMPLE )

*IMPORTANT : In my custom board the EPEN pin is active low so you will see that i have configure it for this behaviour*

ConfigureUSBInterface(void)
{
//
// Enable the uDMA controller and set up the control table base.
// This is required by usblib.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
uDMAEnable();
uDMAControlBaseSet(g_sDMAControlTable);

//
// Enable the USB controller.
//


//
// Set the USB pins to be controlled by the USB controller.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PC6_USB0EPEN);
GPIOPinTypeUSBDigital(GPIO_PORTC_BASE, GPIO_PIN_6);
GPIOPinConfigure(GPIO_PC7_USB0PFLT);
GPIOPinTypeUSBDigital(GPIO_PORTC_BASE, GPIO_PIN_7);
GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);
GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
//
// Register the host class driver
//
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);

//
// 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_LOW | USBHCD_VBUS_FILTER );//| USBHCD_VBUS_FILTER

//
// Force the USB mode to host with no callback on mode changes since
// there should not be any.
//
USBStackModeSet(0, eUSBModeForceHost, 0);

//
// Wait 10ms for the pin to go low.
//

clock = SysCtlClockGet();
SysCtlDelay(SysCtlClockGet()/100);

//
// Initialize the host controller.
//
USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);
}

*THIS IS THE EXACT POINT WHERE I HAVE THE PROBLEM*

So it seam like when i try to power on the USB the debug give me a fault

////////                 ERROR I RECEIVE ON CODECOMPOSER

CORTEX_M4_0: Error connecting to the target
CORTEX_M4_0: Can't Run Target CPU: Debug Port error occurred.

///////

void
USBHostPwrEnable(uint32_t ui32Base)
{
//
// Check the arguments.
//
ASSERT(ui32Base == USB0_BASE);

//
// Enable the external power supply enable signal.
//
HWREGH(ui32Base + USB_O_EPC) |= USB_EPC_EPENDE;    <--------this register configuration give me the fault 
}

i have try a lot of different solution but nothing seam to work ; the pen drive has a led on it so i can see that it light on for 1 sec ;i measure the VBUS , the EPEN and the PFLT and everything is ok.

Thanks in advance for you help and for any other question just ask 

  • Hello Jonny,

    The issue arises when VBUS is applied. It seems to me that when VBUS is enabled, the current drawn by the pen drive is starving the LDO to the TM4C causing a disconnect of the debugger. Can you please check if sufficient current limit has been set on the power source?
  • Hello,
    I tried to verify if i can see any voltage drop on my voltage regulator and i found that when i enable the VBUS i could see that the voltage on microcontroller went below 2.9 voltage causing the reset of the µC.
    So i just add a bigger capacitor on the main voltage line and now everything goes perfectly...thus thank you very much ...probably it was an easy answer but i was stacked checking code instead of give a try also the the electrical behaviour!

    Regards,
    Jonny
  • Hello Jonny,

    More than putting a large capacitor you must also look at the current source and response of the LDO when there is a current inrush.