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.

TM4C129EKCPDT: Application gets hung when boot loader with USB_init() is added to the device. Otherwise it is running fine with bootloader without USB_init().

Part Number: TM4C129EKCPDT

Hello,

I have my boot loader and my application running fine until i initialize the USB. If i directly jump to application without initializing USB, then application runs fine. If i initialize the USB in boot loader, the application gets hung during initialization only. The USB init takes 3 interrupts namely, timer1, usb, and systick. In boot loader i am only using IntMasterDisable() function before jumping to application. Do i need to do anything else before jumping to application.? I think the interrupts are causing some issues with the application.

Regards,

Naman

  • Hi Naman,
    Your bootloader is USB based or via other method? Did the USB after USB_init() is called generate interrupts. Even though you disable via IntMasterDisable() but the interrupts may still be pending. Once you jump to the application you will re-enable interrupts via IntMasterEnable(), would you not?

  • Hi Charles,

    Yes it is a USB bootloader. It uses systick, timer1 and USB0 handler for interrupts.

    I tried using IntMasterEnable() command in application but app got stuck on this command. Then i tried with IntPendClear() to clear all the interrupts for all the 3 peripherals before using it. Still no success.

    I realized that the application was hanging due to timer initializations. I am using timer0 and timer1 and enabling the interrupts for it in application. When i commented their initializations, app was running fine but timers are necessary.

    Then i disabled the timers and USB and systick in bootloader itself before jumping to app. That somehow worked but with a work around. It only works when i initialize USB(with its interrupts) before timer0(with its interrupt). Vice versa does not work. This issue was not there when i was running application directly or without using USB_init in the bootloader. So this issue can rise again.

    Can you suggest anything on this basis?

    Regards,
    Naman
  • HI Naman,
    Can you clarify where it is hanging? When it hanged, was it looping waiting for something?
    Is the timer needed for the bootloader or is it needed for the application? Why do you need to initialize timer in bootloader when you only need them in application? Did you enable the timer as part of the timer initialization? if you enable the timer while in bootloader then the timer starts counting and the interrupt may become pending even though you haven't enable the interrupt. As soon as the interrupts are enabled in application the interrupts are generated.
  • Hi Charles,

    Let me clarify everything. Sorry for that confusion.

    I have a USB Bootloader which can run USB flash drive/pendrive as well as USB keyboard(through switching). I am using timer1 interrupt for key detection of USB keyboard but not in bootloader, it is used in application as we were facing some issues with key detection in USB keyboard as there is a lot of stuff going on in application all the time. In bootloader we are using USB keyboard but it works fine even when the timer1 is not initialized. However, in application we intialize timer1 and its interrupt.

    So in bootloader we have 2 interrupts USB and systick. In application we use timer0 interrupt for sending UART data continuously. So in application interrupts used are USB, systick, timer0, timer1 and ethernet controller interrupt. Now the application runs fine if i remove the USB_init from Bootloader. But as soon as I add USB_init in the booltloader, the application hangs as soon as it reaches to timer0 init(enabling its interrupt as well) after UART is initialized.

    When i commented timer0 init, then it hung at timer1 init which was done after some statements.
    So as i got that the timers were causing issues, before jumping to app in bootloader, i enabled both the timers and then disabled them. I disabled USB peripheral and systick as well. Then somehow it work but with the work around that i already told you. I had to do USB_init before UART_init. I don't know the reason why it is behaving like that.

    As soon as the interrupts are enabled in application the interrupts are generated. Yes i agree. Thats why before using IntMasterDisable(), i disabled all the interrupts and relevant peripherals. Still i wonder why it is not working without that workaround. Did i still left anything enabled in the bootloader which should have been disabled. Do you have any command to check which interrupts are currently available in controller.?

    Regards,
    Naman