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.

LP-AM243: UART Transmission cutting short?

Part Number: LP-AM243
Other Parts Discussed in Thread: UNIFLASH

I ran some tests with the default UART and sent 200 characters and received them on my Visual Studios serial port listener, however when I use the following code to build a buffer (not using the strcpy method from the example), the UART sends a seemingly random lower amount of characters. In this code it should send at least 200 characters with a value of 1 but instead it sends 105. If I change trans.count to 1024 it sends 252.

The system config is the exact same as the UART echo example. I will also attach my VS code for the listener but my previous paragraph should demonstrate its probably not VSCode.

 // Copy Stream to the UART Buffer
    for(i = 0; i < 1024; i++) {
        gUartBuffer[i] = (uint8_t)1;
    }

    // Send UART Stream
    UART_Transaction_init(&trans);
    trans.buf   = &gUartBuffer[0U];
    trans.count = (size_t)200;

    transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
    APP_UART_ASSERT_ON_FAILURE(transferOK, trans);

std::cout << "COM Listener\n";

    int ch = 0;
    char buffer[1];

    /* ... */
    // Open serial port
    HANDLE serialHandle;

    serialHandle = CreateFile(L"\\\\.\\COM6", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);

    // Do some basic settings
    DCB serialParams = { 0 };
    serialParams.DCBlength = sizeof(serialParams);

    GetCommState(serialHandle, &serialParams);
    serialParams.BaudRate = 115200;
    serialParams.ByteSize = 8;
    serialParams.StopBits = ONESTOPBIT;
    serialParams.Parity = NOPARITY;
    SetCommState(serialHandle, &serialParams);

    // Set timeouts
    COMMTIMEOUTS timeout = { 0 };
    DWORD read, written;
    HANDLE keyboard = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);

    timeout.ReadIntervalTimeout = 50;
    timeout.ReadTotalTimeoutConstant = 50;
    timeout.ReadTotalTimeoutMultiplier = 50;
    timeout.WriteTotalTimeoutConstant = 50;
    timeout.WriteTotalTimeoutMultiplier = 10;

    SetCommTimeouts(serialHandle, &timeout);
    
    // basic terminal loop:
    do {
        ReadFile(serialHandle, buffer, sizeof(buffer), &read, NULL);
        WriteFile(screen, buffer, read, &written, NULL);
    } while (streaming != -1);

    CloseHandle(serialHandle);