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.

请教EK-TM4C123GXL 作为USB Host时,USB0VBUS电压问题

按照说明短接了R25,R29

从网站上下载了SW-DK-TM4C123G-2.1.4.178.exe, SW-EK-TM4C123GXL-2.1.4.178.exe

先在板子上下载了第二个安装包中的qs_rgb(EK版本)例程,测试正常。

然后在qs_rgb例程的基础上进行修改,增加usb_host_mouse的功能。(设想是通过ICDI口供电,另外一个位于板子左侧的USB口用于连接mouse device。

现在的问题是,修改后的程序下载到EK的板子上之后,测试USB0VBUS的电压始终是0.61V(分别测试了PB1的针脚和左侧USB口通过OTG线接出来的VC引脚,电压都是0.61v),不知道是什么原因,求大神帮忙分析一下。

代码:

int
main(void)
{
uint32_t ui32Status;
uint32_t ui32ResetCause;
int32_t i32CommandStatus;

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

//
// Set the system clock to run at 50Mhz off PLL with external crystal as
// reference.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);

//
// Configure SysTick for a 100Hz interrupt.
//
ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND);
ROM_SysTickEnable();
ROM_SysTickIntEnable();

//
// Enable Clocking to the USB controller.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

//
// Configure the required pins for USB operation.
//


ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

ROM_GPIOPinConfigure(GPIO_PF4_USB0EPEN);
ROM_GPIOPinTypeUSBDigital(GPIO_PORTF_BASE, GPIO_PIN_4);

ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

//
// Configure PF2 and PF3 as an output.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_3);
//
// Initially wait for device connection.
//
g_eUSBState = STATE_NO_DEVICE;

//
// Initialize the USB stack mode and pass in a mode callback.
//
USBStackModeSet(0, eUSBModeOTG, ModeCallback);

//
// Register the host class drivers.
//
USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers);

//
// Initialized the cursor.
//
g_ui32Buttons = 0;
g_i32CursorX = 0;
g_i32CursorY = 0;

//
// Open an instance of the mouse driver. The mouse does not need
// to be present at this time, this just saves a place for it and allows
// the applications to be notified when a mouse is present.
//
g_psMouseInstance =
USBHMouseOpen(MouseCallback, g_pui8Buffer, MOUSE_MEMORY_SIZE);

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

//
// Initialize the USB controller for OTG operation with a 2ms polling
// rate.
//
USBOTGModeInit(0, 2000, g_pui8HCDPool, HCD_MEMORY_SIZE);

//
// Enable the hibernate module
//
//SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

//
// Enable and Initialize the UART.
//
//ConfigureUART();

//UARTprintf("Welcome to the Tiva C Series TM4C123G LaunchPad!\n");
//UARTprintf("Type 'help' for a list of commands\n");
//UARTprintf("> ");
while(1)
{
//
// Tell the OTG state machine how much time has passed in
// milliseconds since the last call.
//
USBOTGMain(GetTickms());

switch(g_eUSBState)
{
//
// This state is entered when the mouse is first detected.
//
case STATE_MOUSE_INIT:
{
//
// Initialize the newly connected mouse.
//
USBHMouseInit(g_psMouseInstance);

//
// Proceed to the mouse connected state.
//
g_eUSBState = STATE_MOUSE_CONNECTED;

break;
}

case STATE_MOUSE_CONNECTED:
{
//
// Nothing is currently done in the main loop when the mouse
// is connected.
//
break;
}

case STATE_NO_DEVICE:
{
//
// The mouse is not connected so nothing needs to be done here.
//
break;
}

default:
{
break;
}
}


}
//
// Determine why system reset occurred and respond accordingly.
//
ui32ResetCause = SysCtlResetCauseGet();
SysCtlResetCauseClear(ui32ResetCause);
if(ui32ResetCause == SYSCTL_CAUSE_POR)
{
if(HibernateIsActive())
{
//
// Read the status bits to see what caused the wake.
//
ui32Status = HibernateIntStatus(0);
HibernateIntClear(ui32Status);

//
// Wake was due to the push button.
//
if(ui32Status & HIBERNATE_INT_PIN_WAKE)
{
UARTprintf("Hibernate Wake Pin Wake Event\n");
UARTprintf("> ");

//
// Recover the application state variables from battery backed
// hibernate memory. Set ui32Mode to normal.
//
HibernateDataGet((uint32_t*) &g_sAppState,
sizeof(tAppState) / 4 + 1);
g_sAppState.ui32Mode = APP_MODE_NORMAL;
}

//
// Wake was due to RTC match
//
else if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
{
UARTprintf("Hibernate RTC Wake Event\n");
UARTprintf("> ");
//
// Recover the application state variables from battery backed
// hibernate memory. Set ui32Mode to briefly flash the RGB.
//
HibernateDataGet((uint32_t*) &g_sAppState,
sizeof(tAppState) / 4 + 1);
g_sAppState.ui32Mode = APP_MODE_HIB_FLASH;
}
}

else
{
//
// Reset was do to a cold first time power up.
//
UARTprintf("Power on reset. Hibernate not active.\n");
UARTprintf("> ");

g_sAppState.ui32Mode = APP_MODE_NORMAL;
g_sAppState.fColorWheelPos = 0;
g_sAppState.fIntensity = APP_INTENSITY_DEFAULT;
g_sAppState.ui32Buttons = 0;
}
}
else
{
//
// External Pin reset or other reset event occured.
//
UARTprintf("External or other reset\n");
UARTprintf("> ");

//
// Treat this as a cold power up reset without restore from hibernate.
//
g_sAppState.ui32Mode = APP_MODE_NORMAL;
g_sAppState.fColorWheelPos = APP_PI;
g_sAppState.fIntensity = APP_INTENSITY_DEFAULT;
g_sAppState.ui32Buttons = 0;

//
// colors get a default initialization later when we call AppRainbow.
//
}

//
// Initialize clocking for the Hibernate module
//
HibernateEnableExpClk(SysCtlClockGet());

//
// Initialize the RGB LED. AppRainbow typically only called from interrupt
// context. Safe to call here to force initial color update because
// interrupts are not yet enabled.
//
RGBInit(0);
RGBIntensitySet(g_sAppState.fIntensity);
AppRainbow(1);
RGBEnable();

//
// Initialize the buttons
//
ButtonsInit();

//
// Initialize the SysTick interrupt to process colors and buttons.
//
SysTickPeriodSet(SysCtlClockGet() / APP_SYSTICKS_PER_SEC);
SysTickEnable();
SysTickIntEnable();
IntMasterEnable();

//
// spin forever and wait for carriage returns or state changes.
//
while(1)
{

UARTprintf("\n>");


//
// Peek to see if a full command is ready for processing
//
while(UARTPeek('\r') == -1)
{
//
// millisecond delay. A SysCtlSleep() here would also be OK.
//
SysCtlDelay(SysCtlClockGet() / (1000 / 3));

//
// Check for change of mode and enter hibernate if requested.
// all other mode changes handled in interrupt context.
//
if(g_sAppState.ui32Mode == APP_MODE_HIB)
{
AppHibernateEnter();
}
}

//
// a '\r' was detected get the line of text from the user.
//
UARTgets(g_cInput,sizeof(g_cInput));

//
// Pass the line from the user to the command processor.
// It will be parsed and valid commands executed.
//
i32CommandStatus = CmdLineProcess(g_cInput);

//
// Handle the case of bad command.
//
if(i32CommandStatus == CMDLINE_BAD_CMD)
{
UARTprintf("Bad command!\n");
}

//
// Handle the case of too many arguments.
//
else if(i32CommandStatus == CMDLINE_TOO_MANY_ARGS)
{
UARTprintf("Too many arguments for command processor!\n");
}
}
}