9 years, 6 months ago.

serial_api.c file in the FRDM-KL25Z

Does the overrun check required in the following function ?

Is that correct ?

int serial_writable(serial_t *obj) {

check overrun

if (obj->uart->S1 & UART_S1_OR_MASK) {

obj->uart->S1 |= UART_S1_OR_MASK;

}

return (obj->uart->S1 & UART_S1_TDRE_MASK);

}

Question relating to:

mbed library sources mbed

1 Answer

9 years, 6 months ago.

It seems like a fairly pointless check in the write function. Although also the read function ignores it anyway.

Heh editting answers still broken:

This is from the original KL25 mbed implementation, I think written by Freescale. Those parts of the code have never been modified anymore, since they do their job. But if you can verify those lines can be safely removed, go ahead and delete them, and if you want you can then submit a pull request on the mbed github.

posted by Erik - 22 Oct 2014

I think, we can delete this code.

I am using this library (not in mbed ide) in my makefile based project. I see that write function is stuck after transmitting for a bit of time for higher baud rates. I can not re-produce the issue at lower rates.

There is a while loop in the serial write function to check whether the tx buffer is empty or not. I guess that my code stucks here.

The source code looks fine except the overrun code which also should not cause any issue.

Do you think any other flag in the status register to be checked before writing ?

posted by Jags K 24 Oct 2014

It should just check if there is space to transmit the byte, so no flags besides that one should need to be checked.

posted by Erik - 24 Oct 2014