cancel
Showing results for 
Search instead for 
Did you mean: 

USB isr breaks interrupt vector in STM32L1

Kuikui
Associate III
Posted on November 24, 2014 at 14:45

Hi everyone,

I'm using the STM32L151C6

I have a program, running well, debugging with the ST-Link on IAR.

My problem is that as soon as I branch the USB_LP_IRQHandler IRQ to an existing function ( USB_Istr() ) in the startup_stm32l1xx_md.s file, the interrupt vector seems completely broken. It means I can't even debug, as the RESET handler is broken.

I have no idea how to debug this ..

Thanks for help !

BR,

Vincent.
1 REPLY 1
tsuneo
Senior
Posted on November 25, 2014 at 15:30

Are you working on STM32_USB-FS-Device_Lib_V4.0.0 as your USB library?

Then, try this code modification to make the debugger survive. Copied from my previous post, https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex%5fmx%5fstm32%2fUSB%20CDC%20on%20STM32L%20device%20%20unable%20to%20connect%20to%20host Did you disable Suspend on usb_conf.h ? To disable Suspend/Resume behavior completely on this stack, drop CNTR_SUSPM and CNTR_ESOFM from IMR_MSK() definition.

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 )

The Suspend() code (in usb_pwr.c) of this stack drops the entire system into STOP mode. By this code, the device stays in STOP mode, while USB is not plugged in, and until bus reset occurs on USB after plug in. This stack behavior should be ''unexpected'' for self-powered devices ;) I ran Virtual_COM_Port example of STM32_USB-FS-Device_Lib_V4.0.0 on my STM32L-DISCOVERY (with 8MHz crystal). The example was built on Keil under STM32L152-EVAL configuration without any other change. At USB plug in, it enumerated without any trouble (confirmed on a hardware bus analyzer), except the debugger terminated unexpectedly. When I applied above Suspend modification, the debugger survived. Tsuneo