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.

"USB Generic Bulk Device(usb_dev_bulk)" sample code fails on my own board

Other Parts Discussed in Thread: TM4C123BH6PGE, TM4C123GH6PGE

I successfully ran the "USB Generic Bulk Device (usb_dev_bulk)" sample program on the EK-TM4C123GXL lauchpad.

Then using my own board, with part TM4C123BH6PGE with a 25MHz crystal, the code will hangs on USBDBulkInit(0, &g_sBulkDevice); with fault ISR.

I have modified the project setting to fit the part I used. Then I modify the gpio for pin out of USB/LED

I have modify my physical wiring to go as the same with EK-TM4C123GXL except the pin-out.(EK:PD5/PD4; mine: PL6/PL7). here is the code different from the sample code

the red part is whta I modified from the sample code; the blue part is the last statement executed when I ran debug mode.

//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
volatile uint32_t ui32Loop;
uint32_t ui32TxCount;
uint32_t ui32RxCount;

//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();

//
// Set the clocking to run from the PLL at 50MHz
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_25MHZ);

//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);

//
// Enable the GPIO pins for the LED (PM2 & PM3).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_1, GPIO_PIN_1);

//
// Open UART0 and show the application name on the UART.
//
ConfigureUART();

UARTprintf("\033[2JTiva C Series USB bulk device example\n");
UARTprintf("---------------------------------\n\n");

//
// Not configured initially.
//
g_bUSBConfigured = false;

//
// Enable the GPIO peripheral used for USB, and configure the USB
// pins.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);

//
// Enable the system tick.
//
ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
ROM_SysTickIntEnable();
ROM_SysTickEnable();

//
// Tell the user what we are up to.
//
UARTprintf("Configuring USB\n");

//
// Initialize the transmit and receive buffers.
//
USBBufferInit(&g_sTxBuffer);
USBBufferInit(&g_sRxBuffer);

//
// Set the USB stack mode to Device mode with VBUS monitoring.
//
USBStackModeSet(0, eUSBModeForceDevice, 0);

//!!!!!!!!!!!!!!!!!!!!!!!!!   firmware enter fault ISR when this statement is executed !!!!!!!!!!!!!!!!!!!!!!!!!
// Pass our device information to the USB library and place the device
// on the bus.
//
USBDBulkInit(0, &g_sBulkDevice);

//
// Wait for initial configuration to complete.
//
UARTprintf("Waiting for host...\n");

//
// Clear our local byte counters.
//
ui32RxCount = 0;
ui32TxCount = 0;

//
// Main application loop.
//
while(1)
{
//
// See if any data has been transferred.
//
if((ui32TxCount != g_ui32TxCount) || (ui32RxCount != g_ui32RxCount))
{
//
// Has there been any transmit traffic since we last checked?
//
if(ui32TxCount != g_ui32TxCount)
{
//
// Turn on the Green LED.
//
GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_3, GPIO_PIN_3);

//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 150000; ui32Loop++)
{
}

//
// Turn off the Green LED.
//
GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_3, 0);

//
// Take a snapshot of the latest transmit count.
//
ui32TxCount = g_ui32TxCount;
}

//
// Has there been any receive traffic since we last checked?
//
if(ui32RxCount != g_ui32RxCount)
{
//
// Turn on the Blue LED.
//
GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_2, GPIO_PIN_2);

//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 150000; ui32Loop++)
{
}

//
// Turn off the Blue LED.
//
GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_2, 0);

//
// Take a snapshot of the latest receive count.
//
ui32RxCount = g_ui32RxCount;
}

//
// Update the display of bytes transferred.
//
UARTprintf("\rTx: %d Rx: %d", ui32TxCount, ui32RxCount);
}
}
}