Skip to main content
Mike Veltman
Associate
April 18, 2018
Question

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

  • April 18, 2018
  • 6 replies
  • 1499 views
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?

    This topic has been closed for replies.

    6 replies

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

    Hi,

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

    Mike Veltman
    Associate
    April 19, 2018
    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?

    Tobias Wedell
    Associate II
    April 19, 2018
    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.