FRDM K66F-UART Module Configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM K66F-UART Module Configuration

628 Views
michael_schoeff
Contributor I

Good Morning Community,

we want to use a K66f as a gateway between a serial communication and MQTT.

Therefore we combined the examples "frdmkff6_lwip_mqtt_freertos" and "frdmk66f_freertos_uart" from SDK 2.7.0.

Everything works fine except the configuration of the UART Module for our needs.

The serial data structure we are using is as follows:

Start Bit, 7 data bit, even parity bit, two stop bits.

Single characters shall be transmitted and received sequentially.

From the documentation of the K66f, we know that it can be configured to use 7 data bit-messages.

In other configurations, there is the possibility to set the bitCountPerChar but not in the freertos example.

I added the code snipplet (last line), but it can not be used when not commented out. We require a 7 data bit structure.

uart_rtos_config_t uart_config = {
    .baudrate    = 1200,
    .parity      = kUART_ParityEven,
    .stopbits    = kUART_TwoStopBit,
    .buffer      = background_buffer,
    .buffer_size = sizeof(background_buffer),
/*.bitCountPerChar = kUART_7BitsPerChar,*/
};

We tried to work around the problem by adjusting the register configuration in fsl_uart.c driver (last line). The information for the configuration comes from the document K66P144M180SF5RMV2, chapter 59.4.3:

    /* Set bit count/parity mode/idle type. */
    temp = base->C1 &
           ~((uint8_t)UART_C1_PE_MASK | (uint8_t)UART_C1_PT_MASK | (uint8_t)UART_C1_M_MASK | (uint8_t)UART_C1_ILT_MASK);

    temp |= UART_C1_ILT(config->idleType);

    if (kUART_ParityDisabled != config->parityMode)
    {
        temp |= (UART_C1_M_MASK | (uint8_t)config->parityMode);
    }

    //base->C1 = temp;
    /* edit to stop automatic assignment of 9-bit data length because of parity bit*/
    base->C1 = 0x02;

The controller seems not to accept this modification.

When the parity bit is set, the character is not correctly transmitted.

How can we adapt the configuration to solve our problem?

Thanks in advance and best regards,

Michael

Labels (1)
0 Kudos
1 Reply

540 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Michael:

FreeRTOS driver is a wrapper based on uart driver.

I would suggest you add the bitCountPerChar feature in function UART_GetDefaultConfig. ( fsl_uart.c)

/*!
 * @brief Gets the default configuration structure.
 *
 * This function initializes the UART configuration structure to a default value. The default
 * values are as follows.
 *   uartConfig->baudRate_Bps = 115200U;
 *   uartConfig->bitCountPerChar = kUART_8BitsPerChar;
 *   uartConfig->parityMode = kUART_ParityDisabled;
 *   uartConfig->stopBitCount = kUART_OneStopBit;
 *   uartConfig->txFifoWatermark = 0;
 *   uartConfig->rxFifoWatermark = 1;
 *   uartConfig->idleType = kUART_IdleTypeStartBit;
 *   uartConfig->enableTx = false;
 *   uartConfig->enableRx = false;
 *
 * @param config Pointer to configuration structure.
 */
void UART_GetDefaultConfig(uart_config_t *config);

Regards

Daniel

0 Kudos