I am working on a project which uses the USB module integrated into the MSP430F5529, specifically using the MSP-EXP430F5529LP development board from TI. I am using the USB API provided in MSPWare.

The host talks to my device over MODBUS, and I am saving the current baud rate in NVM. Generally, to change the baud rate, I write a value to a MODBUS register. The device reads this value and configures its UARTs accordingly, so that it can act as a bridge between USB and a TTL device.

The problem is that not all MODBUS implementations will use this MODBUS register as a baud rate config, so writing to that address may not be intended to change the baud rate. Therefore, this method has to go.

I was hoping I might be able to detect the baud rate being used to communicate over the USB signal. The first thought was to use a timer to measure the width of the start bit, and use that to calculate the baud rate. The issue with this is that 1) I need to send an entire dummy byte over USB to my device in order to detect the baud rate, before starting normal communication. The other issue is that the way the MSP430 USB API is built, I do not seem to have access to the individual bits as they come in, but rather the message is stored in a buffer which is then provided after the message is completed. I would not be able to time the start bit in this event.

I don't believe there is a way to just "know" what the baud rate of the host is without sending data, since that information (to my knowledge) is not communicated over the bus. Please correct me if I'm wrong.

How might one go about determining the baud rate of a USB connection, preferably without sending a dummy byte first? I'm not entirely convinced this is even possible, it seems to be asking for the impossible, but I figured someone here would be able to give me a definite answer.

I have been through the TI documents describing the USB module, the API, and their application and have not yet found a solution to this problem.


1 Answer 1


The baud rate of the USB connection has no relationship with the baud rate of the UART side of a USB to UART converter. Regardless of the baud rate requested by the application, the data that is sent by the application will be packetized and sent over the USB connection at whatever rate the USB link is configured for (according to speed capabilities of the host and device). It is up to the device to set the baud rate of its UART interface to that requested by the application. The requested baud rate should come in as one of the configuration SET messages sent by the host.

This appnote is for a different platform, but has some information on how this is done: https://www.xmos.com/developer/download/private/AN00124:-USB-CDC-Class-as-Virtual-Serial-Port(2.0.2rc1).pdf

You will have to look in the documentation for your API to see how (or if) this configuration data is exposed. If it is not exposed, you may need to dig through the libraries to find a place where you can intercept that SET message and act on it appropriately.

  • \$\begingroup\$ Thank you very much for the answer. This mostly confirms my suspicion, except for the part about the host sending requested baud rate information. That sounds precisely like what I'm looking for, though I didn't think it was possible. I used some of the terminology from the link you provided to refine my searches (I may have been using poor search terms) and I may have found a possible solution. That being said your answer provides fantastic information and definitely points me in a useful direction. Many thanks! \$\endgroup\$
    – DerStrom8
    Nov 9, 2018 at 0:40
  • \$\begingroup\$ For those interested, to solve this I did the following: In usbEventHandling.c I added a global variable called baudrate. In the USBCDC_handleSetLineCoding() handler, which has lBaudrate as a parameter, I simply set my global baudrate = lBaudrate. Then at the bottom of the file I added an accessor method, uint32_t UsbCdcGetBaudRate(void) which simply returns baudrate. Within my main.c file all I need to do is set a variable = UsbCdcGetBaudRate(). Just as a note I did need to add a file, usbEventHandling.h which contains only the function prototype for UsbCdcGetBaudRate() \$\endgroup\$
    – DerStrom8
    Nov 14, 2018 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.