<?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: Using KSDK for interrupt driven UART? in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407364#M1744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am workig with KDS 3.0 and KSDK1.2.0 and over MQX&lt;/P&gt;&lt;P&gt;I am working with UART1 and UART3 on a K64 device.&lt;/P&gt;&lt;P&gt;Both UART are configured in the same way but &lt;SPAN lang="en"&gt;curiously UART3 sends data and UART1 doesn't. The fact is that when data must be sent through UART1, the interrupt isn't triggered.&lt;/SPAN&gt;&lt;SPAN lang="en"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;Please find attached the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;Any help will be apreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Sep 2015 10:47:02 GMT</pubDate>
    <dc:creator>albertolubeiro</dc:creator>
    <dc:date>2015-09-16T10:47:02Z</dc:date>
    <item>
      <title>Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407358#M1738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like there should be examples, but can anyone point me to information about using KSDK 1.1.0 to initialize and use UART0 for interrupt-driven transmit and receive?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I may also need to use CTS and RTS for flow control.&amp;nbsp; Specifically, I am using a K60 (MK60DN512VLQ10) with a bare-metal configuration (no OS).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'd like are examples showing how to configure the pins, initialize the UART, install the ISR, and handle character transmission and reception using interrupts instead of polling.&amp;nbsp; Since UART0 has a FIFO, it would also be nice to use that to get some better throughput with lower overhead.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp; There may be a great example somewhere, but I just can't find it, and it isn't obvious to me from the KSDK 1.1.0 documentation.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 15:32:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407358#M1738</guid>
      <dc:creator>surrealist14</dc:creator>
      <dc:date>2015-04-14T15:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407359#M1739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let me add some more details from experimentation.&amp;nbsp; I believe that the first thing I need to do is configure the pins I want to use for UART0:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_HAL_SetMuxMode(PORTA_BASE,14u,kPortMuxAlt3); // UART0_TX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_HAL_SetMuxMode(PORTA_BASE,15u,kPortMuxAlt3); // UART0_RX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_HAL_SetMuxMode(PORTA_BASE,16u,kPortMuxAlt3); // UART0_CTS_b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_HAL_SetMuxMode(PORTA_BASE,17u,kPortMuxAlt3); // UART0_RTS_b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also need to allocate space for the UART configuration and state info, and then initialize the UART configuration:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_user_config_t uart0Config; // UART configuration for PC comms&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_state_t uart0State;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Memory for UART driver state structure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart0Config.baudRate = 115200;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart0Config.bitCountPerChar = kUart8BitsPerChar;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart0Config.parityMode = kUartParityDisabled;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart0Config.stopBitCount = kUartOneStopBit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, I call the driver initialization function for the UART:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_DRV_Init(HW_UART0, &amp;amp;uart0State, &amp;amp;uart0Config);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's where I get lost.&amp;nbsp; I'd like to do a non-blocking transmit, for example.&amp;nbsp; I can define a buffer to transmit, and then call the non-blocking driver function to send it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *txBuffer = "Hello from UART0\n\r";&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; size_t txLen = strlen(txBuffer);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_DRV_SendData(HW_UART0, (const uint8_t *)txBuffer, txLen);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The documentation shows that I should be able to check the status of the transmit by calling another driver function, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t txBytesRemaining;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (kStatus_UART_TxBusy == UART_DRV_GetTransmitStatus(HW_UART0, &amp;amp;txBytesRemaining))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Can do something else instead of just busy-waiting here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Presumably this starts sending data and will use a Tx interrupt to handle sending the remaining bytes via the uart_state_t structure as the transmitter empties.&amp;nbsp; However, it appears that the interrupt handler is not being installed correctly.&amp;nbsp; In IAR, I end up at the DefaultISR handler, which just keeps branching back to itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;File fsl_uart_driver.c has the IRQ handler for the UART, but I do not see where it gets installed, or how I should install it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void UART_DRV_IRQHandler(uint32_t instance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function looks like it has the code to handle pending transmits and receives using the uart_state_t structure, but it must get called from some actual ISR, and I do not see where that happens.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do I need to do to install the UART's IRQ handler correctly?&amp;nbsp; There is a function in fsl_interrupt_manager.c to install an interrupt handler and IRQ, but the handler does not take a parameter (instance):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void * INT_SYS_InstallHandler(IRQn_Type irqNumber, void (*handler)(void))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, after I call UART_DRV_Init(), is there something I have to do to install the IRQ handler for the UART?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is greatly appreciated, and I hope this example will help others struggling to use the drivers provided by Freescale.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 19:44:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407359#M1739</guid>
      <dc:creator>surrealist14</dc:creator>
      <dc:date>2015-04-14T19:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407360#M1740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Scott,&lt;/P&gt;&lt;P&gt;We will have UART non-blocking example in the KDS_3.0.0/KSDK_1.2.0 early next month.&lt;/P&gt;&lt;P&gt;Can you wait?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 21:29:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407360#M1740</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2015-04-14T21:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407361#M1741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I am on a very tight schedule, and can't put off finding a solution.&amp;nbsp; I'd be happy to discuss a solution or work-around with you on the phone or via e-mail if it's not ready for the community, or to try out a beta version if it would get me to an answer more quickly.&amp;nbsp; I think that I am very close to having a solution, but the sticking point is that I do not see documentation on how to install the handler for the UART's ISR.&amp;nbsp; I supposed that I could use other fsl_* calls to install my own handler for the ISR, and then have that call the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;void UART_DRV_IRQHandler(uint32_t instance) with an instance of HW_UART0, but I am not sure if that is the correct or Freescale-recommended way.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way you can provide some help or examples to get me past this hurdle?&amp;nbsp; I think it's excellent that KSDK is continuing to evolve and more examples are coming, but I really need to get this piece working ASAP.&amp;nbsp; It's crucial for my application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks, and I appreciate the quick response!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 22:29:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407361#M1741</guid>
      <dc:creator>surrealist14</dc:creator>
      <dc:date>2015-04-14T22:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407362#M1742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Scott Whitney:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To have the ISR function you have to pull a Driver IRQ file to your project (&lt;EM&gt;fsl_&amp;lt;peripheral&amp;gt;_irq.c&lt;/EM&gt;). In this case for UART the file is &lt;STRONG&gt;fsl_uart_irq.c&lt;/STRONG&gt; and it is in the path "C:\Freescale\KSDK_1.1.0\platform\drivers\src\uart). Just copy that file or link it to your project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a document I shared about interrupt handling with KSDK, it is focused for Kinetis Design Studio, but all the concepts apply for any IDE:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/docs/DOC-104352"&gt;Interrupt handling with KSDK and Kinetis Design Studio&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 00:56:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407362#M1742</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-04-15T00:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407363#M1743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jorge, thank you very much.&amp;nbsp; This is exactly what I needed to get me unstuck.&amp;nbsp; What I was missing is that the fsl_&amp;lt;peripheral&amp;gt;_irq.c files are not part of the KSDK platform library build, as you clearly stated in your reply and on page 8 of the document you provided.&amp;nbsp; Once I added fsl_uart_irq.c to my project, the default vector for the UART0 interrupt was replaced, and things started making sense again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great answer, and very timely and helpful.&amp;nbsp; I hope this helps others, and I'm looking forward to KSDK_1.2.0 soon.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:15:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407363#M1743</guid>
      <dc:creator>surrealist14</dc:creator>
      <dc:date>2015-04-15T13:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using KSDK for interrupt driven UART?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407364#M1744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am workig with KDS 3.0 and KSDK1.2.0 and over MQX&lt;/P&gt;&lt;P&gt;I am working with UART1 and UART3 on a K64 device.&lt;/P&gt;&lt;P&gt;Both UART are configured in the same way but &lt;SPAN lang="en"&gt;curiously UART3 sends data and UART1 doesn't. The fact is that when data must be sent through UART1, the interrupt isn't triggered.&lt;/SPAN&gt;&lt;SPAN lang="en"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;Please find attached the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;Any help will be apreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2015 10:47:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Using-KSDK-for-interrupt-driven-UART/m-p/407364#M1744</guid>
      <dc:creator>albertolubeiro</dc:creator>
      <dc:date>2015-09-16T10:47:02Z</dc:date>
    </item>
  </channel>
</rss>

