cancel
Showing results for 
Search instead for 
Did you mean: 

USB Interrupt Skipped on Debug

dsouza1995
Associate II
Posted on April 14, 2016 at 15:16

I'm currently developing a usb device using a stm32f103 and the standard STM USB Library (not HAL). My code works fine in release mode, but on debug mode the USB related interrupts are not called (High and low priority USB and CAN interrupts, named 

USB_HP_CAN1_TX_IRQHandler and 

USB_LP_CAN1_RX0_IRQHandler respectively in my case. You can find their NVIC 

initialisation

below: 

  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =

1

;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority =

1

;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = USB_HP_CAN1_TX_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =

1

;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority =

0

;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

Any insights would be appreciated. 

Daniel 
6 REPLIES 6
Posted on April 14, 2016 at 23:00

Doubt it relates to the code shown here, look at what additional code and diagnostic checks debug mode is adding, and where the system is stuck rather than executing the interrupts. Add telemetry output to help figure out where it is, and why it might have got there.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Radosław
Senior II
Posted on April 14, 2016 at 23:10

first tell what IDE you are using

tsuneo
Senior
Posted on April 14, 2016 at 23:51

> using a stm32f103 and the standard STM USB Library (not HAL)

 

Which library and version are you working on exactly?

I had pointed out many times on this forum,

on STM32_USB-FS-Device_Lib_V4.0.0, debugger dies at USB Suspend, because the Suspend code of this library drops the core into STOP mode. Also, at the start up of enumeration, short Suspend may occur.

To disable Suspend for debugging, modify usb_conf.h of each USB class example.

For example of Virtual_COM_Port,

STM32_USB-FS-Device_Lib_V4.0.0/Projects/Virtual_COM_Port/inc/usb_conf.h

 

/* IMR_MSK */

/* mask defining which events has to be handled */

/* by the device application software */

// #define IMR_MSK (CNTR_CTRM  | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM  | CNTR_SOFM \

//                | CNTR_ESOFM | CNTR_RESETM )

 

// Disable Suspend/Resume response completely

 #define IMR_MSK (CNTR_CTRM  | CNTR_WKUPM | CNTR_ERRM  | CNTR_SOFM | CNTR_RESETM )

Tsuneo

dsouza1995
Associate II
Posted on April 15, 2016 at 10:45

I don't think it would block there either, I posted this since it gives some info on the interrupts that should have been called. My program blocks in :

while(bDeviceState != CONFIGURED);

Which pretty much checks if the device is configured. bDeviceState is set as configured through an interrupt (the low priority one), and is declared as a volatile variable. Thanks for the help!

dsouza1995
Associate II
Posted on April 15, 2016 at 10:47

Hello

I'm using atollic TrueSTUDIO for ARM and I have also checked it on CrossWorks, with the same results ...

Thanks for the help!

dsouza1995
Associate II
Posted on April 15, 2016 at 10:56

Hello,

I'm indeed using STM32_USB-FS-Device_Lib_V4.0.0, however removing suspend didn't solve the issue ...

Thanks for the help!