6 years, 11 months ago.

FRDM-K64F UART format function

Hi,

I found an issue in FRDM-K64F Serial library.

To setup an UART port for 115200bps, 8N1, I wrote a code like this;

Serial uart3(PTC17, PTC16); uart3.baud(115200); uart3.format(8, Serial::None, 1);

But uart3 ends up in 115200bps, 8N2.

I digged in the library source code and found;

static inline void UART_HAL_SetStopBitCount(uint32_t baseAddr, uart_stop_bit_count_t stopBitCount) { BW_UART_BDH_SBNS(baseAddr, stopBitCount); }

at mbed-src/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/uart/fsl_uart_hal.h:421.

SBNS bit should be set to 0 for one stop bit -or- 1 for two stop bits. So, this HAL function should be like this;

BW_UART_BDH_SBNS(baseAddr, stopBitCount>>1);

Any comment is appreciated.

Thanks,

1 Answer

6 years, 11 months ago.

Hello,

I recall I did some fixes (I haven't pushed to main repository yet), si this the one, from my branch:

    uart_stop_bit_count_t stop_count = (stop_bits == 1) ? kUartOneStopBit : kUartTwoStopBit;
    UART_HAL_SetStopBitCount(obj->serial.address, stop_count);

Accepted Answer

Hi,

Sounds perfect. I'm looking forward to updating on main branch.

Thanks,

posted by Mitsuo Mizuno 16 Feb 2015