MSP430 USB Module and Baud Rate Detection

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.

• 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() – DerStrom8 Nov 14 '18 at 16:43