Dear all,
I am trying to build an application in which I need to download data in USB via TIVA C123G launchpad. Has anyone one done this before..?
Please suggest me where to start..?
Are there any relevant examples available for the same..?
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.
Dear all,
I am trying to build an application in which I need to download data in USB via TIVA C123G launchpad. Has anyone one done this before..?
Please suggest me where to start..?
Are there any relevant examples available for the same..?
i have written the following code to detect a pen drive on the TIVA C TM4C123GH6PMI (configured as a USB host). I'm getting errors for undefined identifiers on CCS v6.
Please help in resolving the issues.
//TM4C123GH6PMI USB Host functionality // Basic configuration as a host- mass storage programming example //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 "inc/tm4c123gh6pm.h" #include <stdint.h> #include <stdbool.h> #include "driverlib/gpio.h" #include "inc/hw_gpio.h" #include "driverlib/sysctl.h" #include "inc/hw_sysctl.h" #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "driverlib/debug.h" #include "driverlib/rom.h" #include "driverlib/pin_map.h" //#include "packages/xdc/std.h" //#include "packages/xdc/runtime/System.h" #include "driverlib/usb.h" #include "inc/hw_usb.h" #include "usblib/host/usbhost.h" //contains host mode function prototypes and data types #include "usblib/host/usbhmsc.h" //contains Mass Storage Class definitions specific to hosts #include "usblib/usblib.h" #include "usblib/usbmsc.h" //***************************************************************************** // // The error routine that is called if the driver library encounters an error. // //***************************************************************************** #ifdef DEBUG void __error__(char *pcFilename, uint32_t ui32Line) { } #endif //******************************************************************************************************************************** #define HCD_MEMORY_SIZE 128 //the size of the host controller’s memory size in bytes 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 // USB MSD control #define MSD_NOT_CONNECTED 0 #define MSD_INIT 1 #define MSD_CONNECTED 2 uint32_t iMSDState= MSD_NOT_CONNECTED; //initial value 0 //************************************************************************************************************ // MSCCallBack //************************************************************************************************************* void MSCCallBack (uint32_t ui32Event) { switch (ui32Event) { // new pen drive detected case USB_EVENT_CONNECTED: { iMSDState= MSD_INIT; break; } //pen drive has been unplugged case USB_EVENT_DISCONNECTED: { iMSDState= MSD_NOT_CONNECTED; break; } } } //************************************************************************************************************* //Application Start //************************************************************************************************************** void main (void) { // const tUSBHostClassDriver * const * g_ppsUSBHostClassDrivers; // uint8_t *ptr; // Set the clocking to run from the PLL at 50 MHz SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlUSBPLLEnable(); // enable clocking SysCtlPeripheralEnable (SYSCTL_PERIPH_USB0); //Initialize the USB stack for host mode USBStackModeSet(0,eUSBModeHost,0); //Enable the GPIO peripherals used by the USB pins SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOB); //enable PB0 and PB1 as VBUS and ID pins GPIOPinTypeUSBAnalog (GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // PB0- VBUS; PB1- ID SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOL); // Enable the D+/ D- as USB pins GPIOPinTypeUSBAnalog (GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7); // PL6- D+, PL7- D- SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOG); // configure USBEPEN as a USB pin GPIOPinConfigure (GPIO_PG4_USB0EPEN); GPIOPinTypeUSBDigital (GPIO_PORTG_BASE, GPIO_PIN_4); //***************************************************************************************************************** // LED initialization volatile uint32_t ui32Loop; SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF; ui32Loop = SYSCTL_RCGC2_R; GPIO_PORTF_DIR_R = 0x08; GPIO_PORTF_DEN_R = 0x08; //***************************************************************************************************************** //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 tUSBHMSCInstance *g_psMSCInstance= USBHMSCDriveOpen (0, MSCCallBack); // open an instance of the mass storage class driver USBHCDInit (0, g_pui8HCDPool, HCD_MEMORY_SIZE); // initialize the host controller // main loop of the application while (1) { switch (iMSDState) { //This state is entered when the pen drive is first detected. case MSD_INIT: { //initialize the newly connected pen drive // 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 } //move it to connected state iMSDState= MSD_CONNECTED; break; } case MSD_CONNECTED: { // glow an LED if the pen drive is detected. GPIO_PORTF_DATA_R |= 0x08; for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++); GPIO_PORTF_DATA_R &= ~(0x08); for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++); break; } case MSD_NOT_CONNECTED: default: { break; } } USBHCDMain( ); // Periodic call for the Host Controller Drivers } }
Hello amit,
Thank you for your prompt reply. I will implement it and keep you posted.
Dear amit,
We have done the following changes on the lauchpad:
1) Populated 0 Ohm resistor at R25 and R29
2) shorted H18 and H19 test points
After connection there is +5V available at J9 connector. Is it sufficient or I need to do something else..? coz the pendrive is not getting detected..?
Please help.