This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USCI --> MATLAB COM port communication issues

Other Parts Discussed in Thread: MSP430FG4618

Hi All,

I'm trying to implement an embedded project using the MSP430fg4618. I have an identical isolation layout as the one on the experimenter's board utilizing the same chip. I notice that communication using Docklite and the MATLAB code I'm currently using behaves differently (not exactly sure what it happening though). Basically Docklite works perfectly and Matlab doesn't. I was wondering if anyone could give me some advice after looking at the code below:

The following is the setup for the microcontroller. I'm sending 3 ascii bytes 8-N-1 at 128kBaud (CPU is configured at 7.99 MHz). First byte is basically an identifier for what the input means, while the last two are data bytes (i.e. LSB and MSB of whatever data it corresponds to).

P2SEL |= 0x030;                        

   // P2.4,5 = USCI_A0 RXD/TXD
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK 8MHz
  UCA0BR0 = 64;                             //
  UCA0BR1 = 0;                              //
  UCA0MCTL = 0x08;                          // Modulation
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
Docklite is pretty easy to interface too. I'm simply sending what I want (i.e. 0x416400 corresponds to changing the load on my mechanical loading system to 100 lb) . The problem is MATLAB.
Here is what I'm doing in MATLAB:
% -----------------------------------------------------------------------------------------------------
com = serial('COM3','BaudRate',128000);       % it always connects properly
fopen(com);
com.RequestToSend = 'on';
byte1 = mod(value,256);
byte2 = floor(value/256);
fwrite(com,['A', char(byte1), char(byte2)]);
% ------------------------------------------------------------------------------------------------------
With docklite my load changes perfectly. With MATLAB it changes and then switches back to 0 occasionally. Is it possible that baud rates are out of sync somehow? If so, why would it work and then change? I'm wondering if the matlab code outputs more values than it should or somehow sends twice?
One additional thing to note is that initially i send all COM port devices connected to the cpu 'RRR' and look for a recieved value indicating the device ID. It always works for this device.
Any and all help is much appreciated. Thanks!

**Attention** This is a public forum