4 years, 5 months ago.

stm32f4discovery(stm32f407vg) usb serial output not displayed on serial monitor until speed changed

Hello,

I am trying to run the usb serial port demo, 107 in the listing. I created it using the latest offline compiler for coide. Looks like below. I am using this on a win 7 machine with br@y terminal. The problem I am having is that the output is not displayed on br@y unless I change the speed in br@y. Doesn't matter what speed I change it from or to. If I disconnect br@y and reconnect I have to change the speed again, before output is shown. So, it has something to do with the connection. After I change the speed once, I can keep changing it..and it still outputs. I also tested a similar example with the current cube mx code. It works fine. The output is shown on br@y without having to change the speed. So, I suspect that it has something to do with the software. I checked the defines, everything looks good. I suspect it is due to a callback not being handled in the mbed stack. I think it might be related to the line encoding callback, but not sure. Have you heard of this issue before? Do you know what might be the cause?

By the way, I checked with Realterm. It does not output at all, even if I change the speed. Terraterm works immediately. Nevertheless, I would like to know why the text is not showing on br@y initially. This type of functionality could cause issues with other devices I may use with the usb serial port in future.

include the mbed library with this snippet

#include "mbed.h"
#include "USBSerial.h"

//Virtual serial port over USB
USBSerial serial;
DigitalOut l1(LED1);

int main(void) {
    int i = 0;

    while(1)
    {
        l1 = !l1;
        printf("Hello\r\n");
        serial.printf("I am a virtual serial port: %d\r\n", i++);
        wait(0.1);
    }
}

Question relating to:

USB device stack device, USB
Comment on this question

2 Answers

3 years, 8 months ago.

I have the same problem. What speed did u use to make it show text? Thank u

2 years, 10 months ago.

I'm not sure if this will help but when using the Serial Wire Viewer from ST-Link Utility, you need to change the system clock form whatever it is to 168000000Hz. It seems to keep it after disconnecting.

Happy coding...


You need to log in to post a question