9 years, 5 months ago.

How do I get the timing of serial data sent from Tx on KL25Z ?

Hi,

I am writing some protocol library for mbed with UART. I hope it should work on all mbed boards but there is a problem.

It's famous issue that the irq of Tx are different between NXP and Freescale.

NXP's irq is called just after the data is sent. This means that the irq is called after stop bit is sent ? (sorry I still don't have NXP board)

Freescale's irq is called just after the Tx buffer is empty. This means that the irq is called before stopbit is sent. (I already test this)

The device that I want to drive is half duplex. So I need to switch from Tx to Rx just after stop bit is sent.

.....How do I get this timing on KL25Z ???

(I also hope that mbed library supports half duplex again.....) (Or, should I use MODSERIAL ? :-))

Regards, Zak

2 Answers

9 years, 5 months ago.

I think U will have to use TCIE flag for interrupt "TCIE Transmission Complete Interrupt Enable for TC - 1 Hardware interrupt requested when TC flag is 1 TC Transmission Complete Flag TC is set out of reset and when TDRE is set and no data, preamble, or break character is being transmitted. TC is cleared automatically by one of the following: • Write to the UART data register ( UART _D) to transmit new data • Queue a preamble by changing TE from 0 to 1 • Queue a break character by writing 1 to UART _C2[SBK] - 0 Transmitter active (sending data, a preamble, or a break). - 1 Transmitter idle (transmission activity complete)" instead of TIE flag "Transmit Interrupt Enable for TDRE - 1 Hardware interrupt requested when TDRE flag is 1 Transmit Data Register Empty Flag TDRE is set out of reset and whenever there is room to write data to the transmit data buffer. To clear TDRE, write to the UART data register ( UART _D). - 1 Transmit data buffer empty." in U soft.

Accepted Answer

Thank you for your comment.

Yes, Freescale chip has TCIE flag. And another device that all code is written by me uses this flag to do so. But in this time, I hope to use mbed platform because it's library for all.

Should I write some compile option to separate code for each chip maker ? It's so hard :-).

posted by Kazutaka "Zak" Sawa 29 Oct 2014
9 years, 5 months ago.

I guess you will have to use a wait (or TimeOut) with the time it costs you to send a byte. With the baudrate and the number of bits it sends + some margin this should be relative straightforward.

Thank you for your comment.

But I also hope to access these UART from irq. So I can not use wait function well...it causes irq stop means no other irq will not be called like Rx irq.

Hmmmmm......

posted by Kazutaka "Zak" Sawa 28 Oct 2014