<?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 Re: KL03Z4 LPUART Interrupt (Newbie) in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670429#M41173</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are KL03 LPUART0 initialisation and rx interrupt handling snippets from the uTasker project as reference. You can get complete code from the uTasker open source project at the links below which also enables you to simulate the complete operation to avoid complications, and accelerate learning and developments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This shows the 48MHz IRC48M clock being used as source and configuring for 115'200 Baud.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;#define SPECIAL_LPUART_CLOCK&amp;nbsp; (48000000)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;KINETIS_LPUART_CONTROL lpuart_reg= uart_reg = (KINETIS_LPUART_CONTROL *)UART0_BLOCK; // select the register set for use by this channel&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;POWER_UP(5, SIM_SCGC5_LPUART0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // power up LPUART 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px; color: #ff0000;"&gt;MCG_MC |= MCG_MC_HIRCEN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ensure that the IRC48M is operating, even when the processor is not in HIRC mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px; color: #ff0000;"&gt;SIM_SOPT2 = ((SIM_SOPT2 &amp;amp; ~(SIM_SOPT2_UART0SRC_MCGIRCLK)) | (SIM_SOPT2_UART0SRC_IRC48M | SIM_SOPT2_PLLFLLSEL_IRC48M)); // select the 48MHz IRC48MHz clock as source for the LPUART&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_BAUD = (((SPECIAL_UART_CLOCK/8/115200) + 1)/2); // set 115200&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_CTRL = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 8 bit, no parity&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;_CONFIG_PERIPHERAL(B, 2, (PB_2_LPUART0_RX | UART_PULL_UPS)); // LPUART0_RX on PB2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;_CONFIG_PERIPHERAL(B, 1, (PB_1_LPUART0_TX | UART_PULL_UPS)); // LPUART0_TX on PB1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;fnEnterInterrupt(irq_LPUART0_ID, PRIORITY_LPUART0, _LPSCI0_Interrupt); // enter LPUART0 interrupt handler for rx and tx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_CTRL |= (LPUART_CTRL_RIE | LPUART_CTRL_RE | LPUART_CTRL_TE); // enable transmitter/receiver and rx interrupt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;// LPUART 0 interrupt handler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;//&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;static __interrupt void _LPSCI0_Interrupt(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long ulState = LPUART0_STAT;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // status register on entry to the interrupt routine&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (((ulState &amp;amp; LPUART_STAT_RDRF) &amp;amp; LPUART0_CTRL) != 0) {&amp;nbsp; // reception interrupt flag is set and the reception interrupt is enabled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnSciRxByte((unsigned char)(LPUART0_DATA), LPUART0_CH_NUMBER); // receive data interrupt - read the byte &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ulState = LPUART0_STAT;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the status register&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((ulState &amp;amp; LPUART_STAT_OR) != 0) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if the overrun flag is set at this point it means that an overrun took place between reading the status register on entry to the interrupt and reading the data register&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)LPUART0_DATA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // read the data register in order to clear the overrun flag and allow the receiver to continue operating&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (((ulState &amp;amp; LPUART_STAT_TDRE) &amp;amp; LPUART0_CTRL) != 0) {&amp;nbsp; // transmit buffer is empty and the transmit interrupt is enabled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnSciTxByte(LPUART0_CH_NUMBER);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // transmit data empty interrupt - write next byte, if waiting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not interested in optimal development efficiency and just in correcting your new code I believe that you have &lt;SPAN style="text-decoration: underline;"&gt;forgotten to enable clocks to the LPUART itself&lt;/SPAN&gt;. See&lt;BR /&gt;&lt;STRONG&gt;MCG_MC |= MCG_MC_HIRCEN;&lt;/STRONG&gt; // &lt;EM&gt;optional if the processor is already operating in HIRC mode&lt;/EM&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;STRONG&gt;SIM_SOPT2 = ((SIM_SOPT2 &amp;amp; ~(SIM_SOPT2_UART0SRC_MCGIRCLK)) | (SIM_SOPT2_UART0SRC_IRC48M | SIM_SOPT2_PLLFLLSEL_IRC48M));&lt;/STRONG&gt; &lt;EM&gt;// without this the LPUART is in a frozen state - the edge interrupt will still operate since it is a special asynchronous interrupt but no actual LPUART functions will work yet.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FFRDM-KL03Z.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL03Z.html&lt;/A&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 15 Jul 2017 17:12:55 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2017-07-15T17:12:55Z</dc:date>
    <item>
      <title>KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670428#M41172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a fairly basic question but I am fairly new to this and I have not been able to find any solution. I am trying to initilize an interrupt routine when the Receive Data Register is full for the LPUART function. My debug tests have shown that when I transmit 0x55 into pinB2, there is a detection on the rising edge (LPUART0_STAT(RXEDGIF =1)), but it never fills up the buffer (LPUART0_STAT(RDRF=0)). My register set up is seen below, am I missing something for setting up the registers or is there something else?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/////////////////////////////////////LPUART Setup///////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;//setting System Integration Module//&lt;BR /&gt; SIM_BWR_SOPT5_LPUART0RXSRC(SIM_BASE_PTR, 0); //select LPUART_RX pin to receive data&lt;BR /&gt; SIM_BWR_SCGC5_LPUART0(SIM_BASE_PTR, 1);//enabling UART clock&lt;BR /&gt; SIM_BWR_SCGC5_PORTB(SIM_BASE_PTR, 1);//enables clock gate of Port B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;///////Port Set-up///////&lt;BR /&gt; PORT_BWR_PCR_MUX(PORTB, 2, 0b010); //Set the Alt2 muxing on Port B, pin 2 for UART0_RX&lt;BR /&gt; PORT_BWR_PCR_IRQC(PORTB, 2, 0b1011);//Interrupt configuration to happen on either edge&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //Setting the BAUD register//&lt;/P&gt;&lt;P&gt;//To achieve a baud rate of 300, we want SBR=2 [0000000000010] and OSR=4 [11111]&lt;BR /&gt; LPUART_BWR_BAUD_SBR(LPUART0,0b0000000010110); //Setting SBR =22&lt;BR /&gt; LPUART_BWR_BAUD_OSR(LPUART0, 0b00011); //OSR= x4&lt;BR /&gt; LPUART_BWR_BAUD_RXEDGIE(LPUART0, 1); //enabling hardware interrupts from STAT register&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//setting CTRL register//&lt;BR /&gt; LPUART_BWR_CTRL_RIE(LPUART0, 1); //receiver data buffer full interrupt (1-enable 0-disable)&lt;BR /&gt; LPUART_BWR_CTRL_RE(LPUART0, 1);//enabling receiver mode&lt;BR /&gt; LPUART_BWR_CTRL_IDLECFG(LPUART0, 0b010);//configures 4 idle characters before an idle flag is set&lt;/P&gt;&lt;P&gt;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would really appreciate it and sorry for the relative simplicity of this question. Let me know if you need any more information.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jul 2017 19:30:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670428#M41172</guid>
      <dc:creator>beaurogers</dc:creator>
      <dc:date>2017-07-14T19:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670429#M41173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are KL03 LPUART0 initialisation and rx interrupt handling snippets from the uTasker project as reference. You can get complete code from the uTasker open source project at the links below which also enables you to simulate the complete operation to avoid complications, and accelerate learning and developments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This shows the 48MHz IRC48M clock being used as source and configuring for 115'200 Baud.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;#define SPECIAL_LPUART_CLOCK&amp;nbsp; (48000000)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;KINETIS_LPUART_CONTROL lpuart_reg= uart_reg = (KINETIS_LPUART_CONTROL *)UART0_BLOCK; // select the register set for use by this channel&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;POWER_UP(5, SIM_SCGC5_LPUART0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // power up LPUART 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px; color: #ff0000;"&gt;MCG_MC |= MCG_MC_HIRCEN;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ensure that the IRC48M is operating, even when the processor is not in HIRC mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px; color: #ff0000;"&gt;SIM_SOPT2 = ((SIM_SOPT2 &amp;amp; ~(SIM_SOPT2_UART0SRC_MCGIRCLK)) | (SIM_SOPT2_UART0SRC_IRC48M | SIM_SOPT2_PLLFLLSEL_IRC48M)); // select the 48MHz IRC48MHz clock as source for the LPUART&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_BAUD = (((SPECIAL_UART_CLOCK/8/115200) + 1)/2); // set 115200&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_CTRL = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 8 bit, no parity&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;_CONFIG_PERIPHERAL(B, 2, (PB_2_LPUART0_RX | UART_PULL_UPS)); // LPUART0_RX on PB2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;_CONFIG_PERIPHERAL(B, 1, (PB_1_LPUART0_TX | UART_PULL_UPS)); // LPUART0_TX on PB1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;fnEnterInterrupt(irq_LPUART0_ID, PRIORITY_LPUART0, _LPSCI0_Interrupt); // enter LPUART0 interrupt handler for rx and tx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;lpuart_reg-&amp;gt;LPUART_CTRL |= (LPUART_CTRL_RIE | LPUART_CTRL_RE | LPUART_CTRL_TE); // enable transmitter/receiver and rx interrupt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;// LPUART 0 interrupt handler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;//&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;static __interrupt void _LPSCI0_Interrupt(void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long ulState = LPUART0_STAT;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // status register on entry to the interrupt routine&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (((ulState &amp;amp; LPUART_STAT_RDRF) &amp;amp; LPUART0_CTRL) != 0) {&amp;nbsp; // reception interrupt flag is set and the reception interrupt is enabled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnSciRxByte((unsigned char)(LPUART0_DATA), LPUART0_CH_NUMBER); // receive data interrupt - read the byte &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ulState = LPUART0_STAT;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // update the status register&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((ulState &amp;amp; LPUART_STAT_OR) != 0) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if the overrun flag is set at this point it means that an overrun took place between reading the status register on entry to the interrupt and reading the data register&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)LPUART0_DATA;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // read the data register in order to clear the overrun flag and allow the receiver to continue operating&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (((ulState &amp;amp; LPUART_STAT_TDRE) &amp;amp; LPUART0_CTRL) != 0) {&amp;nbsp; // transmit buffer is empty and the transmit interrupt is enabled&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnSciTxByte(LPUART0_CH_NUMBER);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // transmit data empty interrupt - write next byte, if waiting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier,monospace; font-size: 12px;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not interested in optimal development efficiency and just in correcting your new code I believe that you have &lt;SPAN style="text-decoration: underline;"&gt;forgotten to enable clocks to the LPUART itself&lt;/SPAN&gt;. See&lt;BR /&gt;&lt;STRONG&gt;MCG_MC |= MCG_MC_HIRCEN;&lt;/STRONG&gt; // &lt;EM&gt;optional if the processor is already operating in HIRC mode&lt;/EM&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;STRONG&gt;SIM_SOPT2 = ((SIM_SOPT2 &amp;amp; ~(SIM_SOPT2_UART0SRC_MCGIRCLK)) | (SIM_SOPT2_UART0SRC_IRC48M | SIM_SOPT2_PLLFLLSEL_IRC48M));&lt;/STRONG&gt; &lt;EM&gt;// without this the LPUART is in a frozen state - the edge interrupt will still operate since it is a special asynchronous interrupt but no actual LPUART functions will work yet.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis%2FFRDM-KL03Z.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL03Z.html&lt;/A&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fkinetis.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Jul 2017 17:12:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670429#M41173</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-07-15T17:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670430#M41174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Mark, that was indeed my problem. At the moment I am just looking to fix my code but after some proof of concept I will probably be trying to optimize it.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 14:39:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670430#M41174</guid>
      <dc:creator>beaurogers</dc:creator>
      <dc:date>2017-07-17T14:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670431#M41175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Beau,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you please attached your project here, so that we can help you easier.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Don't know the 'LPUART ASYNCH Module Clock' that you selected, so I am not sure if the baudrate is well configured. But you can check the baudrate through send 0x55 and observe it by oscilloscope.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="LPUART baud rate generation.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/26661i22919D548FCE8E62/image-size/large?v=v2&amp;amp;px=999" role="button" title="LPUART baud rate generation.png" alt="LPUART baud rate generation.png" /&gt;&lt;/span&gt;&lt;BR /&gt;If you select 48MHz IRC48M. To achieve a baud rate of 300, you need set SBR=0x1388 and OSR=0x1F.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommand you test the lpuart example in SDK_2.2_FRDM-KL03Z. You can download it refer &lt;A _jive_internal="true" class="" data-containerid="11554" data-containertype="14" data-objectid="333304" data-objecttype="102" href="https://community.nxp.com/docs/DOC-333304"&gt;Generating a downloadable MCUXpresso SDK v.2 package&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2017 09:30:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670431#M41175</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2017-07-20T09:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670432#M41176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah it works as desired and I was using 0x55 for testing. To get the 300 baud rate I used the 48Mhz internal RC clock and used SBR=4848 (1001011110000) and the OSR=32 (11111). When I send the characters through it detects them correctly. I'm not too sure where you are getting the 1388 SBR value. Using that formula with OSR=32 would suggest a baud rate of around 1048.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2017 13:26:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670432#M41176</guid>
      <dc:creator>beaurogers</dc:creator>
      <dc:date>2017-07-21T13:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670433#M41177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Beau&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SBR = 0x1388 is correct for 300 Baud. This is 5000 and gives exactly 300.0 Baud from a 48MHz clock.&lt;BR /&gt;Your value of 4848 gives 309.4 Baud, which is adequate to operate (+3%) but is not absolutely correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2017 22:40:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670433#M41177</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-07-21T22:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670434#M41178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, I am not quite seeing where the 5000 is coming from and how that gives a 300 baud rate. With the numbers I am using I am finding that my baud rate is IRC48M/(SBR*(OSR+1))=48Meg/(4848*(32+1))=300.03 baud. Is there an aspect that I am not understanding?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Beau&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 12:16:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670434#M41178</guid>
      <dc:creator>beaurogers</dc:creator>
      <dc:date>2017-07-24T12:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670435#M41179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Beau&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RC48M/(SBR*(OSR+1))=48Meg/(4848*(31+1))=309.41&lt;/P&gt;&lt;P&gt;RC48M/(SBR*(OSR+1))=48Meg/(5000*(31+1))=300.00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You were using the wrong value for OSR - is is the value in the register (0x1f = 31).&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 13:24:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670435#M41179</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-07-24T13:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: KL03Z4 LPUART Interrupt (Newbie)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670436#M41180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh I see now, that makes sense. The manual describes setting the OSR register to 11111 as being 32, so that is where my confusion was. I was wondering why there was a +1 in the baud calculation. Thanks a lot Mark and Robin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 13:34:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL03Z4-LPUART-Interrupt-Newbie/m-p/670436#M41180</guid>
      <dc:creator>beaurogers</dc:creator>
      <dc:date>2017-07-24T13:34:58Z</dc:date>
    </item>
  </channel>
</rss>

