PSoC 6 WIFI-BT Pioneer Kit serial over USB

I have a PSoC WIFI-BT Pioneer kit
I want to do serial over the non-programming USB connection
I am using Mbed Studio
I am using the code from https://os.mbed.com/docs/mbed-os/v6.2/program-setup/serial-communication.html
Two issues:

  1. It does not create a USB serial port (COM) I can use with putty. If I close the Mbed Studio, I can use putty (9600, 8n1) on the COM11. I want to use the other USB connector on the Kit board - the one attached to the PSoC
  2. this is my sample code (starting from the example code):
    #include “mbed.h”

static BufferedSerial pc(USBTX, USBRX);
static BufferedSerial uart(D1, D0);

// Blinking rate in milliseconds
#define BLINKING_RATE 200ms

int main()
{
char uartbuf[1];
int count = 0;

printf( "start\n" );

while (1)
{
    uartbuf[0] = 0x55;
    uart.write( uartbuf, sizeof(uartbuf));
    //pc.write( uartbuf, sizeof(uartbuf));
    printf( "%u ", count++ );
    uart_activity = !uart_activity;

    ThisThread::sleep_for(BLINKING_RATE);
}

}

I see:
A. The 0x55 is on the D0/D1 pins - what I want
B. the 0x55 is on the debug COM11 output - it should NOT be on the debug output

924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 93UUUUUUUUUUUUUUUU9 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 95UUUUUUUUUUUUUUUU5 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 97UUUUUUUUUUUUUUUU1 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 98UUUUUUUUUUUUUUU7 988 989

C. If I change the inner code to:

    uartbuf[0] = 0x55;
    uart.write( uartbuf, sizeof(uartbuf));
    uartbuf[0] = 0x41;
    pc.write( uartbuf, sizeof(uartbuf));
    printf( "%u ", count++ );
    uart_activity = !uart_activity;

    ThisThread::sleep_for(BLINKING_RATE);

Note the UUU becomes UAUAUA

UAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUA0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19A20 UAUAUAUAUAUAUAUAUAUA1 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 26UAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUA7 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 28UAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUA3 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 29UAUAUAUAUAUAUAUAUAUAUAUAUAUAUAUA9 300 301 302 303 304 305

So:

  1. How do I specify the USB port on the “user” USB?
  2. Why does the write the UART also write to the debug port?

Thanks … bandit

Hello,

Use a USBSerial interface to emulate a serial port over USB rather than an UART port.

The “programming” USB connector is connected to the Mbed UART’s D1, D0 pins over an on-board USB-to-UART converter. The USBTX is an alias name of the D1 pin and the USBRX of the D0 pin. Hence, when you create two objects like:

static BufferedSerial pc(USBTX, USBRX);
static BufferedSerial uart(D1, D0);

then both the pc and uart objects actually represent the same UART interface. That’s why both print to the same virtual serial port (serial terminal) on the PC (using the USB driver of the on-board USB-to-UART converter installed to the PC during the Mbed board setup procedure). In addition, the global printf function (and the similar debug function) also prints to the same UART (aka “Serial console” or stdout). However, it is possible to remap the global printf (and bebug) function to other UART. For more details read here. If you need a serial connection using streams then this library can be handy too.

Best regards, Zoltan