<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using Multiple LPUARTS in different Ports in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-Multiple-LPUARTS-in-different-Ports/m-p/1318094#M61145</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Microcontroller - NXP Kinetis MKE14F512VLL16&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IDE - MCUXpresso v11.3.0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SDK - SDK_2.x_MKE14F512XXX16 ,v2.8.8&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've an application in which I have to use the same LPUART module in two different ports. Different peripheral is connected to each port and I don't want to use them simultaneously.&lt;/P&gt;&lt;P&gt;Peripheral 1(P1) is connected to:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTA3 (ALT6)- LPUART0-TX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTA2 (ALT6)- LPUART0-RX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peripheral 2(P2) is connected to:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTB0 (ALT2)- LPUART0-RX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTB1 (ALT2)- LPUART0-TX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In my application, I'm initializing the LPUART0 module with Port A2 and A3 using the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void InitLPUART0(void){
PCC-&amp;gt;CLKCFG[PCC_LPUART0_INDEX] |= PCC_CLKCFG_PCS(3); //System Oscillator Bus Clock
PCC-&amp;gt;CLKCFG[PCC_LPUART0_INDEX] |= PCC_CLKCFG_CGC(1); //PCC Configuration - Enable Clock

PORTA-&amp;gt;PCR[2] |= PORT_PCR_MUX(6); /* LPUART - ALT6 */
PORTA-&amp;gt;PCR[3] |= PORT_PCR_MUX(6);

LPUART0-&amp;gt;CTRL &amp;amp;= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
LPUART0-&amp;gt;BAUD = BAUD_115200; //48M/(26*16)Baud rate for 115200bps

LPUART0-&amp;gt;CTRL |= LPUART_CTRL_RIE(1); /* Receiver Interrupt Enable */
LPUART0-&amp;gt;CTRL |= LPUART_CTRL_TE(1); /* Transmitter enable */
LPUART0-&amp;gt;CTRL |= LPUART_CTRL_RE(1); /* Receiver Enable */

NVIC_EnableIRQ(LPUART0_RX_IRQn); 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially ,this is working as expected. The system is sending data as expected through the port.&lt;/P&gt;&lt;P&gt;When I need to use the other peripheral, I'm shifting the LPUART0 to the other port as shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;LPUART0-&amp;gt;CTRL &amp;amp;= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK); /* Disable Tranceiver */

PORTA-&amp;gt;PCR[3] |= PORT_PCR_MUX(1); /* LPUART - ALT1 - GPIO */
PORTA-&amp;gt;PCR[2] |= PORT_PCR_MUX(1);

PORTB-&amp;gt;PCR[0] |= PORT_PCR_MUX(2); /* LPUART - ALT2 - UART */
PORTB-&amp;gt;PCR[1] |= PORT_PCR_MUX(2);

LPUART0-&amp;gt;CTRL |= (LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK); /* Enable Tranceiver */&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After shifting the system is supposed to send the data through the Port B to peripheral 2. But the LPUART lines are idle even though the transmission code is running. After switching ports, if I switch back to peripheral 1 in Port A using the same method, it doesn't respond either.&lt;/P&gt;&lt;P&gt;The system is working if use either of the ports without switching to the another.&lt;/P&gt;&lt;P&gt;What is wrong in this method?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Aug 2021 12:06:15 GMT</pubDate>
    <dc:creator>CEPL_Dev</dc:creator>
    <dc:date>2021-08-04T12:06:15Z</dc:date>
    <item>
      <title>Using Multiple LPUARTS in different Ports</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-Multiple-LPUARTS-in-different-Ports/m-p/1318094#M61145</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Microcontroller - NXP Kinetis MKE14F512VLL16&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IDE - MCUXpresso v11.3.0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SDK - SDK_2.x_MKE14F512XXX16 ,v2.8.8&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've an application in which I have to use the same LPUART module in two different ports. Different peripheral is connected to each port and I don't want to use them simultaneously.&lt;/P&gt;&lt;P&gt;Peripheral 1(P1) is connected to:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTA3 (ALT6)- LPUART0-TX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTA2 (ALT6)- LPUART0-RX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peripheral 2(P2) is connected to:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTB0 (ALT2)- LPUART0-RX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PTB1 (ALT2)- LPUART0-TX&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In my application, I'm initializing the LPUART0 module with Port A2 and A3 using the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void InitLPUART0(void){
PCC-&amp;gt;CLKCFG[PCC_LPUART0_INDEX] |= PCC_CLKCFG_PCS(3); //System Oscillator Bus Clock
PCC-&amp;gt;CLKCFG[PCC_LPUART0_INDEX] |= PCC_CLKCFG_CGC(1); //PCC Configuration - Enable Clock

PORTA-&amp;gt;PCR[2] |= PORT_PCR_MUX(6); /* LPUART - ALT6 */
PORTA-&amp;gt;PCR[3] |= PORT_PCR_MUX(6);

LPUART0-&amp;gt;CTRL &amp;amp;= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);
LPUART0-&amp;gt;BAUD = BAUD_115200; //48M/(26*16)Baud rate for 115200bps

LPUART0-&amp;gt;CTRL |= LPUART_CTRL_RIE(1); /* Receiver Interrupt Enable */
LPUART0-&amp;gt;CTRL |= LPUART_CTRL_TE(1); /* Transmitter enable */
LPUART0-&amp;gt;CTRL |= LPUART_CTRL_RE(1); /* Receiver Enable */

NVIC_EnableIRQ(LPUART0_RX_IRQn); 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Initially ,this is working as expected. The system is sending data as expected through the port.&lt;/P&gt;&lt;P&gt;When I need to use the other peripheral, I'm shifting the LPUART0 to the other port as shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;LPUART0-&amp;gt;CTRL &amp;amp;= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK); /* Disable Tranceiver */

PORTA-&amp;gt;PCR[3] |= PORT_PCR_MUX(1); /* LPUART - ALT1 - GPIO */
PORTA-&amp;gt;PCR[2] |= PORT_PCR_MUX(1);

PORTB-&amp;gt;PCR[0] |= PORT_PCR_MUX(2); /* LPUART - ALT2 - UART */
PORTB-&amp;gt;PCR[1] |= PORT_PCR_MUX(2);

LPUART0-&amp;gt;CTRL |= (LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK); /* Enable Tranceiver */&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After shifting the system is supposed to send the data through the Port B to peripheral 2. But the LPUART lines are idle even though the transmission code is running. After switching ports, if I switch back to peripheral 1 in Port A using the same method, it doesn't respond either.&lt;/P&gt;&lt;P&gt;The system is working if use either of the ports without switching to the another.&lt;/P&gt;&lt;P&gt;What is wrong in this method?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 12:06:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-Multiple-LPUARTS-in-different-Ports/m-p/1318094#M61145</guid>
      <dc:creator>CEPL_Dev</dc:creator>
      <dc:date>2021-08-04T12:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multiple LPUARTS in different Ports</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-Multiple-LPUARTS-in-different-Ports/m-p/1318121#M61146</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;Just found out the solution. I was overwriting bits 8, 9 and 10 corresponding to the &lt;STRONG&gt;MUX&lt;/STRONG&gt; settings in the &lt;STRONG&gt;PORTx_PCR&lt;/STRONG&gt; register instead of clearing them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Corrected method is posted below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void SelectCOMPort(COMPORT_TYPE CPort){ /* Directs LPUART0 to the required port and disables others */
	LPUART0-&amp;gt;CTRL &amp;amp;= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);	/* Disable Tranceiver */
	switch (CPort)
	{
	case PORT_1:
		PORTB-&amp;gt;PCR[0] &amp;amp;= ~(BIT8 | BIT9 | BIT10); 	/* LPUART - Disable */
		PORTB-&amp;gt;PCR[1] &amp;amp;= ~(BIT8 | BIT9 | BIT10);

		PORTA-&amp;gt;PCR[3] |= PORT_PCR_MUX(6); 			/* LPUART - ALT6 - to UART */
		PORTA-&amp;gt;PCR[2] |= PORT_PCR_MUX(6);

		break;
	case PORT_2:
		PORTA-&amp;gt;PCR[3] &amp;amp;= ~(BIT8 | BIT9 | BIT10);  	/* LPUART - Disable */
		PORTA-&amp;gt;PCR[2] &amp;amp;= ~(BIT8 | BIT9 | BIT10);

		PORTB-&amp;gt;PCR[0] |= PORT_PCR_MUX(2); 			/* LPUART - ALT2 - to UART */
		PORTB-&amp;gt;PCR[1] |= PORT_PCR_MUX(2);
		break;
	default:
		break;
	}
	LPUART0-&amp;gt;CTRL |= (LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);	/* Enable Tranceiver */
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2021 12:09:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Using-Multiple-LPUARTS-in-different-Ports/m-p/1318121#M61146</guid>
      <dc:creator>CEPL_Dev</dc:creator>
      <dc:date>2021-08-04T12:09:58Z</dc:date>
    </item>
  </channel>
</rss>

