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.

problem in USB detection with tm4c123gh6pm

this is the code i have written for configuring the microcontroller as USB host device:

//The following code shows the basic setup code needed for any application that is using the USB library in host mode. The g_pui8HCDPool array which is passed to the USBHCDInit( ) is used as a heap memory for by the USB library and thus should not be used by the application. In this example, the g_ppsHostClassDrivers array holds the MSC (mass storage class) drivers. The macros provided in the pin_map.h file included with DriverLib can be used to indicate which pin and peripheral to use for a given part. The USBHCDRegisterDrivers( ) call passes in the static array of supported USB host class drivers that are supported by the application. Typically, the reading or writing to a device is left to a file system layer or through direct read and write calls.

	#include "usbhost.h"      //contains host mode function prototypes and datatypes
	#include "usbhmsc.h"    //contains Mass Storage Class definitions specific to hosts
	#include "usb.h"
	#include "gpio.h"
	#include "usblib.h"
	#include "hw_usb.h"
	#include "xdc/std.h"
	#include "xdc/runtime/System.h"
	#include "ti/sysbios/BIOS.h"
	#include <stdint.h>
	#include "debug.h"
	#include <stdbool.h>
	#include "usbmsc.h"
	#include "tm4c123gh6pm.h"
	#include "hw_gpio.h"
	#include "hw_memmap.h"
	#include "hw_sysctl.h"
	#include "hw_types.h"
	#include "rom.h"
	#include "sysctl.h"
	#include "pin_map.h"
	#include "usbhscsi.h"


	#define HCD_MEMORY_SIZE 128    //the size of the host controller’s memory size in bytes

	void main (void)
	{


		const tUSBHostClassDriver * const * g_ppsUSBHostClassDrivers;
		tUSBHMSCInstance * g_psMSCInstance;
		uint8_t *ptr;
	// Set the clocking to run from the PLL at 50 MHz
		ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
		unsigned char g_pui8HCDPool [HCD_MEMORY_SIZE];  //the memory pool to provide to the host controller driver
		static tUSBHostClassDriver const  *const g_ppsHostClassDrivers[]={ &g_sUSBHostMSCClassDriver };
	// the global that holds all of the host drivers in use in the application
		static const unsigned long g_ui32NumHostClassDrivers =	sizeof (g_ppsHostClassDrivers) / sizeof (tUSBHostClassDriver * );
	//this global holds the number of class drivers in the g_ppsHostClassDrivers list
	//Enable the GPIO peripherals used by the USB pins
		MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOB);
		MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOG);
		MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOL);
	// configure USBEPEN as a USB pin
		MAP_GPIOPinConfigure (GPIO_PG4_USB0EPEN);
		MAP_GPIOPinTypeUSBDigital (GPIO_PORTG_BASE, GPIO_PIN_4);
	//enable PB0 and PB1 as VBUS and ID pins
		MAP_GPIOPinTypeUSBAnalog (GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	// Enable the D+/ D- as USB pins
		MAP_GPIOPinTypeAnalog (GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
	//Initialize the USB stack for host mode
		USBStackModeSet(0,eUSBModeHost,0);
	//Register the host class drivers
		USBHCDRegisterDrivers (0, g_ppsUSBHostClassDrivers, g_ui32NumHostClassDrivers);
	// Initialize the power configuration. Set the power enable signal to be active high and does not enable the power fault.
		USBHCDPowerConfigInit (0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);
	// call any open routines here for the application to be ready for a new mass storage device
		g_psMSCInstance= USBHMSCDriveOpen (0, MSCCallBack);	 // open an instance of the mass storage class driver
	// wait for the drive to become ready- wait for the value to go to 0 before the host controller attempts to read or write from the device.
		while ( USBHMSCDriveReady (g_psMSCInstance))
			{
			SysCtlDelay(g_ui32ClockRate / 100);                          //delay given for the device to be ready
			}

		USBHCDInit (0, g_pui8HCDPool, HCD_MEMORY_SIZE);

	//read or write to the device
		USBHMSCBlockRead(g_psMSCInstance, 0, ptr, 1);
	}


i am encountering the following error

The build settings i have updated are as follows

Please help me understand this error.

  • Hi,

      There are USB examples at Tivaware, compare it to your code.

      

    surabhi bhosale said:
    #include "usbhost.h"
      

       Try these below instead.

    #include "usblib/host/usbhost.h"
    #include "usblib/host/usbhmsc.h"

       Regarding your Build Warning Message, you can adjust Compiler Version at Project Properties->General->Compiler Version. Adjust Compiler Version to TI v5.1.5.

    - kel