2016-04-14 06:16 AM
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
initialisationbelow: 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.
Daniel2016-04-14 02:00 PM
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.
2016-04-14 02:10 PM
first tell what IDE you are using
2016-04-14 02:51 PM
> 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 ) Tsuneo2016-04-15 01:45 AM
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!
2016-04-15 01:47 AM
Hello
I'm using atollic TrueSTUDIO for ARM and I have also checked it on CrossWorks, with the same results ...
Thanks for the help!
2016-04-15 01:56 AM
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!