<?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 KL25/26 receive from multiple UARTs in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25-26-receive-from-multiple-UARTs/m-p/499636#M31186</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to connect to 2 devices on UART0 and UART1.&lt;/P&gt;&lt;P&gt;I get this problem when I open both UART0 and UART1:&lt;/P&gt;&lt;P&gt;After opening first UART: I can read/write on first UART properly.&lt;/P&gt;&lt;P&gt;After opening second UART: I can read/write on&amp;nbsp; second UART, but i can only write to the first UART. trying to receive from the first UART blocks and crashes the application (eventually).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, they both work correctly when only one of them is opened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do i need to do to receive from both UARTs properly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have my clocks setup like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14550893439142934" data-renderedposition="281_8_1050_80" jivemacro_uid="_14550893439142934"&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SOPT2 &amp;amp;= ~SIM_SOPT2_UART0SRC_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;SOPT2 |= (uint32_t)SIM_SOPT2_UART0SRC(0x01); //0x4000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;SOPT2 |= (uint32_t)SIM_SOPT2_PLLFLLSEL_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;CLKDIV1 &amp;amp;= ~SIM_CLKDIV1_OUTDIV4_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;CLKDIV1 |= SIM_CLKDIV1_OUTDIV4(0x01);&amp;nbsp; //0x10000&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UART0 is setup like this: using serial_api.h from mbed.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14550893940076982 jive_macro_code jive_text_macro" data-renderedposition="424_8_1050_80" jivemacro_uid="_14550893940076982" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_init(&amp;amp;_serial0, PTA2, PTA1);&amp;nbsp; //24, 23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_handler(&amp;amp;_serial0, serial0_irq_handler, &amp;amp;_serial0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_set(&amp;amp;_serial0, RxIrq, TRUE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_baud(&amp;amp;_serial0, 57600);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UART1 is setup like this: (also using serial_api.h from mbed).&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14550896040606184 jive_text_macro" data-renderedposition="546_8_1050_64" jivemacro_uid="_14550896040606184"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_init(&amp;amp;_serial1, PTC4, PTC3);&amp;nbsp; //49, 46&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_handler(&amp;amp;_serial1, serial1_irq_handler, &amp;amp;_serial1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_set(&amp;amp;_serial1, RxIrq, TRUE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_baud(&amp;amp;_serial1, 57600);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both UARTs are using a ringbuffer for in the ISR of receive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Feb 2016 07:50:11 GMT</pubDate>
    <dc:creator>michaelnetshipi</dc:creator>
    <dc:date>2016-02-10T07:50:11Z</dc:date>
    <item>
      <title>KL25/26 receive from multiple UARTs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25-26-receive-from-multiple-UARTs/m-p/499636#M31186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to connect to 2 devices on UART0 and UART1.&lt;/P&gt;&lt;P&gt;I get this problem when I open both UART0 and UART1:&lt;/P&gt;&lt;P&gt;After opening first UART: I can read/write on first UART properly.&lt;/P&gt;&lt;P&gt;After opening second UART: I can read/write on&amp;nbsp; second UART, but i can only write to the first UART. trying to receive from the first UART blocks and crashes the application (eventually).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, they both work correctly when only one of them is opened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do i need to do to receive from both UARTs properly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have my clocks setup like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14550893439142934" data-renderedposition="281_8_1050_80" jivemacro_uid="_14550893439142934"&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SOPT2 &amp;amp;= ~SIM_SOPT2_UART0SRC_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;SOPT2 |= (uint32_t)SIM_SOPT2_UART0SRC(0x01); //0x4000000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;SOPT2 |= (uint32_t)SIM_SOPT2_PLLFLLSEL_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;CLKDIV1 &amp;amp;= ~SIM_CLKDIV1_OUTDIV4_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM-&amp;gt;CLKDIV1 |= SIM_CLKDIV1_OUTDIV4(0x01);&amp;nbsp; //0x10000&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UART0 is setup like this: using serial_api.h from mbed.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14550893940076982 jive_macro_code jive_text_macro" data-renderedposition="424_8_1050_80" jivemacro_uid="_14550893940076982" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_init(&amp;amp;_serial0, PTA2, PTA1);&amp;nbsp; //24, 23&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_handler(&amp;amp;_serial0, serial0_irq_handler, &amp;amp;_serial0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_set(&amp;amp;_serial0, RxIrq, TRUE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_baud(&amp;amp;_serial0, 57600);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UART1 is setup like this: (also using serial_api.h from mbed).&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14550896040606184 jive_text_macro" data-renderedposition="546_8_1050_64" jivemacro_uid="_14550896040606184"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_init(&amp;amp;_serial1, PTC4, PTC3);&amp;nbsp; //49, 46&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_handler(&amp;amp;_serial1, serial1_irq_handler, &amp;amp;_serial1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_set(&amp;amp;_serial1, RxIrq, TRUE);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_baud(&amp;amp;_serial1, 57600);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both UARTs are using a ringbuffer for in the ISR of receive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2016 07:50:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25-26-receive-from-multiple-UARTs/m-p/499636#M31186</guid>
      <dc:creator>michaelnetshipi</dc:creator>
      <dc:date>2016-02-10T07:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: KL25/26 receive from multiple UARTs</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25-26-receive-from-multiple-UARTs/m-p/499637#M31187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out that calling serial_irq_handler() replaces the old handler w/ a new one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;serial_api.c&lt;/P&gt;&lt;P&gt;void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; irq_handler = handler;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; serial_irq_ids[obj-&amp;gt;index] = id;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2016 14:30:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL25-26-receive-from-multiple-UARTs/m-p/499637#M31187</guid>
      <dc:creator>michaelnetshipi</dc:creator>
      <dc:date>2016-02-10T14:30:58Z</dc:date>
    </item>
  </channel>
</rss>

