µTasker UART/LPUART Interface
Kinetis devices originally contained a number of UARTs, with up to 6 available in some parts - such as the K60. More recently newer parts started appearing with LPUARTs (Low Power UARTs), for example the KL03 with a single LPUART. However some parts can also include both types, such as the KL43 with two LPUARTs plus a single UART, or the K22 with 3 UARTs and a single LPUART.
UARTs and LPUARTs have various differences and the question that arises when using a driver interface is how can they be handled in a generic manner so that appliation code is compatible as well as how are the channels numbered in the µTasker interface?
The majority of UART and LPUART's capabilities are the same or very similar; they both support DMA operation for example. The UART interface remains compatible for application use as detailed in the µTasker UART User's Guide and the UART is referenced purely by its channel number. This referencing is of course simple when the device contains only UARTs or only LPUARTS because the numbering is simple 0 for UART0/LPUART0, 1 for UART1/LPUART1, 2 for UART2/LPUART2 etc. but the actual integration of the different type in Kinetis derivatives with mixed types doesn't necessarily follow a strict system.
Consider the KL43, which has three UARTs; LPUART0, LPUART1 and UART2. Here the channel numbering is still pretty clear because channel 0 would logically be for the LPUART0 and channel 2 for the UART2 and one could think that that is already the end of the story. However then consider the K22, which has 4 UARTs; UART0, UART1, UART2 and LPUART0. Now this system has already broken because both the first UART and the first LPUART are used. While for the KL43 channel 0 is for an LPUART, the K22's channel 0 is now for a UART - and how can LPUART0 now be addressed since channels 0, 1 and 2 are already used?
The following table shows how the number has been specified at the µTasker application interface, showing four basic devices types and their UART/LPUART integration.
|Channel||Only UARTs||Only LPUARTs||LPUARTs followed by UART||UARTs and LPUARTs|
The table shows how there are essentially two cases when the device has both UARTs and LPUARTs. If the UARTs are numbered according to their addressing (column "LPUARTs followed by UART") the channel numbering continues to match the physical controller addressing. If however both UARTs and LPUARTs are numbered physically so that there is both a UART and an LPUART with the same controller numbering (column "UARTS and LPUARTs") then the UARTs have priority and the LPUARTs follow the UARTs - in the particular case in the table it means that LPUART0 is references in the software as channel 2.
The mixed type columns were constructed based on KL43 and K22 parts with limited UART/LPUARTS. The strategy extends however to other such devices with mixed types and to parts that may be introduced in the future into the Kinetis family.
For specific questions and feedback on this topic please use the following forum entry: Kinetis UART / LPUART Referencing.
µTasker UART / LPUART Interface. Copyright (c) 2004..2018 M.J.Butcher Consulting