KL25Z USB serial port vanishes after downloading code

23 Jun 2013

On the KL25Z, if I write any program that transmits to the USB serial port and download it to the board it will work, but I need to shut down my terminal emulator (Tera Term), start it up again and re-open the serial port before I get anything. Why is this?

I am using Windows 7 - 64 bit.

Here's my test program :

serial port test program

#include "mbed.h"

Serial pc( USBTX, USBRX );

int main() {
    int ch = 'A';
    while(1) {
        pc.putc( ch++ );
        if( ch > 'Z' ) {
            ch = 'A';
        wait( 0.25f );

It may have something to do with the way downloading and restarting is done on the KL25Z which seems to be a bit different to the LPC1768 and LPC11U24. On these, after a download, you just have to press the reset button and away it goes, serial port working fine. However, on the KL25Z I notice that after a download two things are different:

1. The program does not appear on the KL25Z drive (I know this is by design).

2. Windows plays the noise that indicates a disconnected USB device and shortly afterwards plays the noise that indicates a connected USB device. This never happens on the other 2 devices. Serial port now doesn't work until I have restarted the terminal program. It seems to have lost track of the serial port.

Just to be clear, to get it to work I need to do this:

1. Set up Tera Term for the right serial port, baud rate and so on and open the port.

2. Serial data can be seen coming in from the KL25Z.

3. Compile and download my program to the KL25Z.

4. Press the KL25Z's reset button.

5. No serial data can be seen coming in from the KL25Z.

6. Quit from Tera term.

7. Start up Tera Term.

8. Set up Tera Term for the right serial port, baud rate and so on and open the port.

9. Serial data can be seen coming in from the KL25Z.

Do I just have to put up with this, or this there a workaround?

On the other two devices I can just start up Tera Term once at the start of the day and just leave it open all day through multiple compile and download cycles.

27 Jun 2013

As you mentioned, the device is disconnected/reconnected.
This is also mentioned in the Results box at http://mbed.org/handbook/mbed-FRDM-KL25Z-Downloading.
As a result, the com port disappears on disconnect and reappears on connect.

You don't need to restart TeraTerm to reconnect.
Carry out following actions while TeraTerm is still open:

  • Click on File and choose Disconnect (or use ALT-I).
  • Again, click on File and choose New Connection (or use ALT-N).
  • Select Serial, choose your COM port and click on OK.

The connection will be established again.

27 Jun 2013


On some of your Tera Term steps:

1. Once you set up baud rate, etc., you can save Tera Term setup. Under tab Setup >> Save Setup

6, 7 & 8. Use Alt-I and Alt-N as Frank describes above - you'll be an expert in no time (lol)

It ain't much, but it helps. The problem with USB Serial (vs RS-232) is that the USB driver in Windows breaks the USB connection if a device is powered down or disconnected. You have to manually re-establish the connection again. Talk to Bill Gates if you have a problem with this.


27 Jun 2013

Thanks Frank. I figured this out shortly after I posted. It helps a bit.

Kevin. In the end I did save my settings. This also helps.

It's just slightly more difficult than on the other m-beds, but it isn't a huge problem. I suppose the reason the USB device has to power down is because there is no external flash memory on the KL25Z to use as a memory stick whereas on the other m-beds there is.

10 Jul 2013

While searching for some other stuff, I came across following Notebook page to auto-connect TeraTerm to the mbed:
Even though Python is needed, it can be a valuable tool.

12 Jun 2016

FWIW If you use Putty instead of Teraterm it has a simple "restart session" function which should get it to reconnect.

13 Jun 2016

I'm using OpenSDA FW and USB driver from P&E Micro
With this I don't have to quit/restart TeraTerm every time I reset the board.