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.

MSP430F55x interface with serial port problem

Other Parts Discussed in Thread: MSP430F5509

Hi,

I am new to MSP family.I am trying to read send data from MSP430F5509 through USB interface to Host PC.On PC side i am using MATLAB to read from serial port.But i could read data from serial port only the first time i make connection.If i close and try to reopen the connection in matlab meaning try to connect to serial port MATLAB says it could nt find the 'COM' port.I could still see the com port on the PC.I have to relaunch Matlab and reconnect the hardware to establish connection again.

Is this problem with my code?

switch(USB_getConnectionState())
{
// This case is executed while your device is connected to the USB
// host, enumerated, and communication is active. Never enter
// LPM3/4/5 in this mode; the MCU must be active or LPM0 during USB
// communication.
case ST_ENUM_ACTIVE:

USBCDC_sendDataInBackground(buffer,sizeof(buffer),CDC0_INTFNUM,0);
break;


// These cases are executed while your device is:
case ST_USB_DISCONNECTED:// physically disconnected from the host
case ST_ENUM_SUSPENDED:// connected/enumerated, but suspended
case ST_NOENUM_SUSPENDED:// connected, enum started, but the host is unresponsive

// In this example, for all of these states we enter LPM3. If
// the host performs a "USB resume" from suspend, the CPU will
// automatically wake. Other events can also wake the
// CPU, if their event handlers in eventHandlers.c are
// configured to return TRUE.
__bis_SR_register(LPM3_bits + GIE);
break;

// The default is executed for the momentary state
// ST_ENUM_IN_PROGRESS. Almost always, this state lasts no more than a
// few seconds. Be sure not to enter LPM3 in this state; USB
// communication is taking place, so mode must be LPM0 or active.
case ST_ENUM_IN_PROGRESS:
default:;
}

} //while(1)
} //main()


/*
* ======== UNMI_ISR ========
*/
#if defined(__TI_COMPILER_VERSION__) || (__IAR_SYSTEMS_ICC__)
#pragma vector = UNMI_VECTOR
__interrupt void UNMI_ISR(void)
#elif defined(__GNUC__) && (__MSP430__)
void __attribute__ ((interrupt(UNMI_VECTOR))) UNMI_ISR (void)
#else
#error Compiler not found!
#endif
{
switch (__even_in_range(SYSUNIV, SYSUNIV_BUSIFG))
{
case SYSUNIV_NONE:
__no_operation();
break;
case SYSUNIV_NMIIFG:
__no_operation();
break;
case SYSUNIV_OFIFG:
UCS_clearAllOscFlagsWithTimeout(0);
SFR_clearInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);
break;
case SYSUNIV_ACCVIFG:
__no_operation();
break;
case SYSUNIV_BUSIFG:
// If the CPU accesses USB memory while the USB module is
// suspended, a "bus error" can occur. This generates an NMI, and
// execution enters this case. This should never occur. If USB is
// automatically disconnecting in your software, set a breakpoint
// here and see if execution hits it. See the Programmer's
// Guide for more information.
SYSBERRIV = 0; // Clear bus error flag
USB_disable(); // Disable USB -- USB must be reset after a bus error
}
}

//Released_Version_5_00_01

MATLAB

s = serial('COM16'); %assigns the object s to serial port
set(s, 'BaudRate', 9600);
raw=zeros(6000,1);
% set(s, 'Parity', 'none');
% set(s, 'StopBits', 1);
fopen(s);


for i=1:1000
raw{i} = fread(s, 6,'uint8');
end
figure
plot(raw);
%out = fread(s,6)
fclose(s);
delete(s);
clear s;

Can plaese someone help me with this problem.?

I need to send some data from MSP430 and read in a file on PC.If anyone has example code please share..

  • Hi,

    Based on your Matlab code and the description of the COM port it sounds to me like you are using UART communication as compared to true USB. It appears that when you close the connection in Matlab you are failing to actually disconnect the program from the COM port, therefore retaining the hold such that no other programs can access the device until Matlab is closed out completely and the COM port is released. You would probably notice that in this state that other terminal programs would not be able to recognize the COM port as well. There should be some command in Matlab that releases the port before disconnecting from it, otherwise I do not believe this to be an issue with the MSP430 firmware.

    Regards,
    Ryan

**Attention** This is a public forum