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: ISR registered for USB in device mode never get invoked

Part Number: EK-TM4C123GXL

I’m using Tiva C series launchpad EK-TM4C1123GXL, staffed with TM4C 123GPMH MPU.
I’m trying to code USB bulk device operation. Example doesn’t work- failed to enumerate, according dmesg. So I have  no chance o use provided libusb. So , I put on my glasses and start coding.
I initialize USB0 with following code. My ISR does nothing, but light BLUE LED. Guess what- no matter what I do, connect/ disconnect cable, try to enumerate device. ISR got never called, and LED was not lit.
Please direct me or hint what are my mistakes. Any help appreciated.

#define USB_PINDM  GPIO_PIN_4 /* portD GPIO pin 4 GPIO_PIN_4  d-*/
#define USB_PINDP  GPIO_PIN_5 /* portD GPIO pin 5 GPIO_PIN_5 d+*/

#define USB_PINID  GPIO_PIN_0 /* PORTB  GPIO pin 4 GPIO_PIN_0  id*/
#define USB_PINVBUS GPIO_PIN_1 /* PORTB GPIO pin 5 GPIO_PIN_1 vbus*/
//++++++++++++++++++++++++++++++++configure USB++++++++++++++++++++++++++++
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);// Signal lines
   while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD)) ;;// Signal lines
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);/*/ ID,VBUS*/
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB));;

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);//id,vbus lines
   while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB)) ;; //id,vbus lines


GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, (USB_PINID | USB_PINVBUS));/* ID(pin0),VBUS(pin1)*/
GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, (USB_PINDM | USB_PINDP));// Signal lines

GPIOPadConfigSet(GPIO_PORTB_BASE,(USB_PINID | USB_PINVBUS),GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);// pull down for ID, VBUS pins
USBModeConfig(USB_MODE_DEV_VBUS,0);

 SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

 while(!SysCtlPeripheralReady(SYSCTL_PERIPH_USB0));;
    SysCtlUSBPLLEnable();
   USBClockEnable(USB0_BASE, 7/*8*/, USB_CLOCK_INTERNAL);
    IntDisable(INT_USB0);
USBIntDisableControl(USB0_BASE, (uint32_t)USB_INTCTRL_ALL);/*prevent interrupt by a glitch */
USBIntRegister(USB0_BASE, USB0_ISR_handle); /* REGISTER CALLBACK*/
USBIntEnableControl(USB0_BASE, USB_INTCTRL_RESET |
            USB_INTCTRL_DISCONNECT |
            USB_INTCTRL_RESUME |
            USB_INTCTRL_SUSPEND |
            USB_INTCTRL_SOF);

    IntEnable(INT_USB0);
        USBIntEnableEndpoint(USB0_BASE, USB_EP_0);
            USBIntEnableEndpoint(USB0_BASE, USB_EP_1);

  • Hello Alexander,

    Are you using a TIvaWare example? usb_dev_bulk?

    If so, then the enumeration issue is likely because you don't have the right USB drivers installed.

    Please get our latest drivers from: software-dl.ti.com/.../SW-TM4C-2.1.4.178.PATCH-1.0.zip and then install them via Device Manager. You likely will need to manually install them.
  • Hello Ralph, thank you so much for your time and efforts! I downloaded the zip file. It contains windows drivers, I'm working with Linux OS. I guess the problem is with libusb itself. Actually to my understanding the enumeration happened before driver get invoked, therefore enumeration is done on kernel level, before loading driver to determine which driver need to be used for particular device... therefore libusb should be OS independent.
  • Hello Alexander,

    Ahh I see, I didn't know you were on Linux, yes the drivers I shared are for Windows specifically. That said, the TM4C USB library can be used for enumerating in Linux, we just don't have TI offered drivers for Linux. However, many customers have had success with modifying TI drivers for Linux purposes, and they didn't need to change the USB library code.

    Here is an E2E post where with some guidance a community member was able to make the USB driver they needed and it is for the exact example you are wanting to use as well: https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/612214/2254101#2254101

    Also a commonly shared resource which has helped others with Linux USB drivers is: https://kernel.readthedocs.io/en/sphinx-samples/writing_usb_driver.html

  • Hello Ralph, thank you for the input, but my problem isn't os driver! But rather soft that is flashed on board... By the Way, I gave another try for usblib and dev_bulk example. Now I even can't compile codenow , too many errors to list them. D you know where I can download latest and greatest example and library? Once again, I'm positive that it isn't os driver, it is code on board or unit itself Can you explain, please why ISR get never invoked?
  • Hello Alexander,

    The library and software example can be downloaded from: http://www.ti.com/tool/SW-TM4C

    Just ran the code and it runs fine on Windows, enumerating as a TivaWare Bulk Driver properly.

    Note that you need to have the USB cable plugged into the Device Port for the LaunchPad to see it. If you want to program and see it at the same time, that will require two cables. If you only have one, then you program the device, and then switch the cable to the Device port as well as flip the switch to Device.

    Regarding the ISR, do you mean USB0DeviceIntHandler? If so, that is because USB0DeviceIntHandler is inside of the library file for usblib, so unless you unlink the library and link in all the needed USB files into your project manually, you won't be able to enter the ISR as it is packed within the library file. Though why you need to see the ISR for USB get invoked still isn't clear to me as I haven't had that come up before as an issue...
  • HEllo Ralph, thank you so much for your your time. I went trhrough your links, it seemsthat are libraries

     that I already have installed from the same page...
    I'm using USBIntRegister(USB0_BASE, USB0_ISR_handle); API function to register ISR, I tried to hardcode it in vector array in the startup file, the result is the same - ISR got never called.
    The reason, I'm going down this road and have chosen this API- because I need to develop USB communication tailored for my need And I have to evaluate, whether I can use for this purpose TI's processor.

    Monitoring whether ISR got called, is just a 1st checkpoint n the process of developing the routine.
    Thanks,

    Alex.

  • Hello Alexander,

    That explains a lot more to me.

    Our USB examples are based on our usblib whereas what you are trying to use the usb.c/usb.h file from driverlib. While we provide those files for completion of our offering, you should be working with usblib for determining how to develop your tailored USB firmware. That is how all our customers develop USB applications.

    The ISR for bulk device mode is handled by USB0DeviceIntHandler which is the main USB interrupt handler entry point for use in USB device applications. This function is included in usbdhandler.c and you can read the full description for it there.

    I would recommend you read through our TivaWare USB Library document in the docs folder so you can familiarize yourself with our full USB library.
  • Hello Alexander,

    Have you made any progress on this? Do we still need to keep this thread open, or can I go ahead and close it?
  • Hi Alexander,

    I think what Ralph is trying to say (indirectly) is you have mostly just configured GPIO's for USB0 but have not yet initialized the targets bulk device driver to establish an endpoint pipe to Linux OS. You can modify the USB bulk device project files for visual studio, an example of character echo typed from compiled (usb_bulk_exampe.vcproj/exe) it's not an Linux IPM. The target USB code is the Tiva bulk device (usb_dev_bulk.c) which you can modify via CCS. The bulk device example may be in the examples folder of the Tivaware library files, it used to be a separate download, don't see it listed  anymore (separately) as it past was. It may be bundled in the USB library files now.

    http://software-dl.ti.com/tiva-c/SW-TM4C/latest/index_FDS.html