Author Topic: Microcontroller USB serial issue with initial connection to serial monitor  (Read 9373 times)

jimmy

  • Member
  • ***
  • Posts: 2
Hello,

I bought your book USB 4th ed, great book. I have encountered a problem that I was hoping you might be able to help me with. I have a STM32F429 micrcontroller. I want to use it to communicate to my Windows 7 64 bit pc.I am using mbed with a c++/c stack. It is lacking all of the code to establish a USB connection with this microcontroller, so I modified it to make it work. I used ST Micros working USB code as a reference. I checked the ST Micros USB code, it works as expected, on both Terraterm and Br@y terminal. So, I modified mbed, it works, but I am having a small issue on the initial connection. The code is just printing "Hello" at 1 ms intervals. When I connect Terraterm, it works right away, no matter what speed(baud) setting I have it on. On the Br@y terminal I see nothing, not until I change the speed. It does not matter what the initial speed is. It doesn't matter what speed I change it to. So, I am not sure what the issue is. I suspect that I am either handling an event improperly or not responding to an event. Due to the complexity of the code, it is difficult to decifer what the difference is between the mbed and the STM code. Have you ever encountered this situation before? Do you know what event I might be missing? Do you know what Br@y terminal might be doing differently on establishing the communication?

Thanks,

-jimmy

Tsuneo

  • Frequent Contributor
  • ****
  • Posts: 145
Re: Microcontroller USB serial issue with initial connection to serial monitor
« Reply #1 on: February 24, 2015, 05:17:38 am »
Quote
Do you know what Br@y terminal might be doing differently on establishing the communication?

I had once looked in TeraTerm source code closely, when I was asked a question like yours; a CDC device works well on TeraTerm, but not on other terminals. Generally speaking, TeraTerm has little interest in device errors; It doesn't check GetLastError() after calling Serial APIs in most of its code sequence. And then, your device could "work well", even if it would return errors. I believe Br@y would honestly respond to errors pf your device.


Quote
On the Br@y terminal I see nothing, not until I change the speed.

It sounds like, once the internal holding of line_coding structure is written by Set_Line_Coding, everything works well. Did you initialize the line_coding structure by appropriate default value?

Code: [Select]
LINE_CODING linecoding =
  {
    115200, /* baud rate*/
    0x00,   /* stop bits-1*/
    0x00,   /* parity - none*/
    0x08    /* nb. of bits 8*/
  };

Tsuneo

jimmy

  • Member
  • ***
  • Posts: 2
Re: Microcontroller USB serial issue with initial connection to serial monitor
« Reply #2 on: February 24, 2015, 11:35:49 pm »
Thanks Tsuneo,

Yes, I didn't comment but I did see that function being called when using the debugger on the micro. I thought that might be it. I will take a look. See if making a change will fix the issue.

-jimmy