10 years, 8 months ago.

What's the problem with my virtual USB serial port on FRDM-KL25Z?

I tested the code below on my FRDM-KL25 board, it didn'twork. But it did work sevral days ago. now i need to import another library(USBSerial.h) to carry on whit my project. anybody knows what the problem is? thankyou.

Best Regards, Eugene

/*---------------*/

  1. include "mbed.h"

DigitalOut myled(LED_GREEN); Serial pc(USBTX, USBRX);

int main() { int i = 0; pc.printf("\nHello World!\n");

while (true) { wait(0.5); pc.printf("%d \n", i); i++; myled = !myled; } }

1 Answer

10 years, 8 months ago.

Serial PC(USBTX, USBRX) is something different as USBSerial.

The first one, which you have in your code posted here, uses the SDA USB port of the KL25Z. It is a regular serial connection connected to an IC which makes it a USB com port. The USBSerial one makes the KL25Z itself act directly as USB com port, and requires the KL25's USB connector. They also require different drivers.

If the first one doesn't work, make sure you haven't connected anything to PTA1 and PTA2, since those pins are used for the connection.

Thanks for your response. do you mean that Serial PC(USBTX, USBRX) is actually used to contral MK20 and makes it as a USB Serial port?if we download wrong firmware into MK20, then KL25Z cannot contral MK20 and make it as a USB Serial port?

posted by Yuting You 24 Mar 2014

Well it doesn't actually control the MK20, but it does send via normal serial connection (UART) the data to the MK20, which converts it to a USB virtual COM port. If you got wrong firmware in the MK20 it might not work, but why would you have wrong firmware in the MK20?

posted by Erik - 24 Mar 2014