2014-03-08 06:51 AM
Hi, I have a fairly standard implementation of the Virtual COM Port for the STM32F103. All i have implemented currently is the VCP code and an LED flashing in the main loop.
The board can be powered by either USB or External Power supply.Everything works fine when powered by USB, i.e. VCP works and LED flashes in main routine. When i pull the USB cable while also powering the board by the external power supply the STM32 seems to lock up and the LED stops flashing (stays solid). As soon as i plug the USB back in the LED begins flashing again?!?!Has anyone come across anything like this before? I really need the STM32 to continue to function as normal when powered by the external power supply with the USB either plugged in or not plugged in. #usb-virtual-com-port2014-03-08 12:22 PM
Maybe some noise on usb data line, you can try to disable suspend and wakeup irqs.
It may help or not.2014-03-08 04:39 PM
The STM32 locks up when the USB cable is unplugged so i dont think it would be noise on the USB lines?
2014-03-09 06:58 AM
While the device is plugged off, it goes to Suspend.
Are you working on STSW-STM32121 (STM32_USB-FS-Device_Lib_V4.0.0)? As the default behavior, this device stack drops the entire system into STOP mode, while USB is suspending. This feature is fine for bus-powered devices, to satisfy the suspend current requirement (less than 2.5mA) of the USB spec. But for self-powered devices, like your case, this feature is not always preferred. You may disable suspend/resume detection by dropping CNTR_SUSPM and CNTR_ESOFM from IMR_MSK() definition in usb_conf.hSTM32_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 )
OR
If you would still need suspend/resume detection, but you don't like STOP mode,
modify Suspend() code in usb_pwr.c, so that it doesn't drop in to STOP mode
STM32_USB-FS-Device_Lib_V4.0.0/Projects/Virtual_COM_Port/src/usb_pwr.c
void Suspend(void)
{
...
// delete the code after this line
/*prepare entry in low power mode (STOP mode)*/
/* Select the regulator state in STOP mode*/
...
}
Tsuneo
2014-03-09 07:47 AM
Hi thanks for your reply, yes i am using STM32_USB-FS-Device_Lib_V4.0.0 and what you say makes a lot of sense as it is very much like the device goes to sleep and resumes exactly where it was once the usb cable is plugged back in, i will test out the modification tomorrow and report back.
thanks!2014-04-11 12:20 AM
Hi,
Am also trying to port VCP project available with STM32_USB-FS-Device_Lib_V4.0.0 on STM32103XC. Disabling Suspend / Resume works fine and helped in making USB to get into attached state for controller. But after that it's not going to CONFIGURED STATE.Did you face same issue after changing code as above? What can be the possible issue for device not getting configured and getting detected on host pc.
Regards,
Omji Mishra
2014-04-13 11:30 PM
2014-04-15 08:34 AM
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.