AnsweredAssumed Answered

Open port error on host while using HAL_Delay

Question asked by Kozlov.Dmitrii on Dec 19, 2016
Latest reply on Jan 10, 2017 by Kozlov.Dmitrii

I use STM32F407G-DISC1 board. I have run some examples with VCP based on STD library. Everything is OK. Then I have tried to generate code by CubeMX. And something interesting happens.

If not to add any code, then VCP is defined by host and Terminal can connect that.

If I add CDC_Transmit_FS in endless loop of main(), it works

volatile uint32_t time_var = 3e7;
while (1){   
    while(time_var) {
CDC_Transmit_FS(b, 4);
time_var = 3e8;}

If instead of internal while loop I use HAL_Delay function, then terminal can't open the port.

while (1) {
    CDC_Transmit_FS(b, 4);}

So, COM port is defined in DeviceManager, but terminal can't connect that. It happens even before the first call of CDC_Transmit_FS, though hUsbDeviceFS is already initialized. The following code runs OK again.

while (1) {
//CDC_Transmit_FS(b, 4);}

I have tried to increase Heap size, it doesn't help.