Jaccon Bastiaansen

LPUART interrupt driven character transmission

Discussion created by Jaccon Bastiaansen on Nov 1, 2017
Latest reply on Nov 17, 2017 by Bob Paddock

We are writing an interrupt driven driver for the LPUART on the KL17 and KL13 (note that for several reasons, we write our own driver instead of using the driver provided by MCUxpresso).


For the transmission part of the driver, we want to enable the transmit interrupt (the TIE bit in the CTRL register) when there is new data to transmit. When the transmit interrupt occurs and there is no more data to send, the driver should disable the transmit interrupt again. The problem is that the CTRL register description in the LPUART chapter of the Kinetis reference manual states that “This register should only be altered when the transmitter and receiver are both disabled”. The CTRL register description also states that after setting the TE and RE bits to zero, an ongoing character transmission and reception have to finish first before the transmitter and receiver are really disabled.


So in order to disable the transmit interrupt in an ISR, we should:

  • Set the TE and RE in the CTRL register to zero
  • Wait until TE and RE become zero
  • Set TIE in the CTRL register to zero


The waiting time (2nd step) can take the time for one character to be received/transmitted which is a long time (when using a low baud rate) to spend in an ISR.


When looking in the driver provided by MCUXpresso (see attachment), we see that the TE and RE bits are not cleared when disabling and enabling the TIE bit in the CTRL register.


So our question is: under which circumstances can we enable/disable the LPUART interrupt sources? Is the manual too strict when stating that all bits in the CTRL register can only be modified when the transmitter and receiver are both disabled?