cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to connect with USB CDC after minor changes (I.E. defining a new variable)

Mike Veltman
Associate II
Posted on April 18, 2018 at 14:43

So I just started developing with the STM32F Discovery board and the only thing I'm facing are problems. The biggest problem is that one time I can connect to the virtual comport using RealTerm, and the other time it says its using 'Invalid Parameters' so I can never connect. I set breakpoints and in the debugger I can clearly see my code is running. So I slowed down the amount of times I'm doing operations to once per 10ms and then it started work again.

The last problems I'm facing that I can't connect to the board with Realterm when I'm creating a new variable for instance. There's nothing wrong in the syntax, it just won't connect anymore. When I make a comment of the variable, it works, when I uncomment it, it stops working. The same goes for many other things. For instance when I'm trying to free some memory I allocated earlier it doesn't let me connect whilst the code still runs.

It's so weird when I change code that doesn't give any errors and its syntax is right it makes me unable to connect (the code wasn't even called).

Another example, when I create a new function in main. Put some logic in it, like B = A + C and leave the function alone so I'm not calling it. It also doesn't let me connect to the STM32.. But when I remove the logic inside the never-called function it lets me connect.

I'm only experiencing problems with the STM32 sadly.. Anyone knows a fix which allows me to write code for the STM32 without it crashing on the USB CDC connection?

6 REPLIES 6
Tobias Wedell
Associate II
Posted on April 18, 2018 at 17:23

Hi,

first of all try to increase the heap and/or stack memory for your project.

Posted on April 19, 2018 at 10:02

Hello,

Thanks for the quick answer first of all.

Yes, I have increased the heap and stack size when I generated the code with CubeMx.

Heap is 0x2000 and Stack is 0x4000 big, might not be enough. Do you know a proper way to allocate the right amount of memory for the heap and stack size?

Posted on April 19, 2018 at 11:51

I think your Heap and Stack is very big. In my USB CDC projects I use for Heap 0x400 and for Stack 0x800.

What a IDE you're using for compiling? Some IDEs come with their own startup file and don't use the one that is generated by CubeMX. So you have to change heap and stack manually in the startup file.

Have you read this:

Maybe you find some hints.

Posted on April 19, 2018 at 11:55

I'm using Eclipe as an IDE.

I will look through the doc you provided.

Posted on April 24, 2018 at 10:27

To no avail it's still not working..

Here's a link to stackoverflow for a bit more detailed description of the problem:

https://stackoverflow.com/questions/49915065/stm32f4-unable-to-connect-with-usb-cdc-after-minor-changes-i-e-defining-a-new

 
Posted on April 24, 2018 at 10:49

I just found something which made connection via USB not possible:

addressTable[0].type = ISU;      //Just to test. Needs to be set by USB

addressTable[0].address = 1;

Whenever I uncomment those lines my code 'crashes', the code is still running but I can't connect via USB CDC anymore.

It has to do with creating an array and/or setting values inside of it.