<?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>LPC Microcontrollers中的主题 Re: Problem mixing polling and interrupt ROM-based UART</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560396#M16079</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Sun Aug 31 04:48:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah, yes, thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Turned out I had some serious timing issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To solve those I switched to the ringbuffer UART driver.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the ringbuffer thread safe? I get data in the receive buffer that's never received over the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Since I heavily use the ringbuffer from the main thread while bytes come in I suspect that the main thread and interrupt are colliding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remco Poelstra&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:00:39 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:00:39Z</dc:date>
    <item>
      <title>Problem mixing polling and interrupt ROM-based UART</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560394#M16077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Fri Aug 29 08:27:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm mostly using the UART with the ROM drivers in interrupt mode. This works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try to receive a buffer in polling mode then the code seems to crash. Pausing the code gives the following output in the debugger:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thread [1] &amp;lt;main&amp;gt; (Suspended : Signal : SIGINT:Interrupt)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x1fff1af4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x1fff1bec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x1fff1bec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I assume it is stuck in an interrupt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried calling NVIC_DisableIRQ(UART0_IRQn); before using the polling mode, but it still gets stuck in the interrupt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to mix interrupt and polling mode?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UART setup code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void UART0_IRQHandler(void)
{
LPC_UART_API-&amp;gt;uart_isr(uartHandle);
}

void setupUART(void) {
uint32_t frg_mult;

Chip_Clock_SetUARTClockDiv(1);/* divided by 1 */

Chip_UART_Init(LPC_USART0);

/* 115.2KBPS, 8N1, ASYNC mode, no errors, clock filled in later */
UART_CONFIG_T cfg = {
0,/* U_PCLK frequency in Hz */
115200,/* Baud Rate in Hz */
1,/* 8N1 */
0,/* Asynchronous Mode */
NO_ERR_EN/* Enable No Errors */
};

/* Setup the UART handle */
uartHandle = LPC_UART_API-&amp;gt;uart_setup((uint32_t) LPC_USART0, (uint8_t *) &amp;amp;uartHandleMEM);

cfg.sys_clk_in_hz = Chip_Clock_GetSystemClockRate();

/* Initialize the UART with the configuration parameters */
frg_mult = LPC_UART_API-&amp;gt;uart_init(uartHandle, &amp;amp;cfg);
if (frg_mult) {
Chip_SYSCTL_SetUSARTFRGDivider(0xFF);/* value 0xFF should be always used */
Chip_SYSCTL_SetUSARTFRGMultiplier(frg_mult);
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the interrupt mode:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/* Enable the IRQ for the UART */
NVIC_EnableIRQ(UART0_IRQn);

_param.buffer = (uint8_t *) receive_buffer;
_param.size = length;

_param.transfer_mode = RX_MODE_LF_RECVD;
_param.driver_mode = DRIVER_MODE_INTERRUPT;

/* Setup the receive callback, this will get called when the
&amp;nbsp;&amp;nbsp; transfer is complete */
_param.callback_func_pt = callback;

/* Receive the data */
LPC_UART_API-&amp;gt;uart_get_line(uartHandle, &amp;amp;_param);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;_param is a global variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using polling mode:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;UART_PARAM_T param;

/* Enable the IRQ for the UART */
NVIC_DisableIRQ(UART0_IRQn);

param.buffer = (uint8_t *) receive_buffer;
param.size = length;

param.transfer_mode = RX_MODE_BUF_FULL;
param.driver_mode = DRIVER_MODE_POLLING;

/* Receive the data */
LPC_UART_API-&amp;gt;uart_get_line(uartHandle, &amp;amp;param);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any insights would be highly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remco Poelstra&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560394#M16077</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem mixing polling and interrupt ROM-based UART</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560395#M16078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Fri Aug 29 09:07:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That's not in an interrupt (if it was, you would still see the stack frames). The PC indicates you are in the ROM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would suggest you have stack corruption (something is overwriting your stack and when a call returns, it jumps off into the weeds).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560395#M16078</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem mixing polling and interrupt ROM-based UART</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560396#M16079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Sun Aug 31 04:48:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah, yes, thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Turned out I had some serious timing issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To solve those I switched to the ringbuffer UART driver.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the ringbuffer thread safe? I get data in the receive buffer that's never received over the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Since I heavily use the ringbuffer from the main thread while bytes come in I suspect that the main thread and interrupt are colliding.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remco Poelstra&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560396#M16079</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem mixing polling and interrupt ROM-based UART</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560397#M16080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Sun Aug 31 07:12:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok, that previous bug was caused by LPCExpresso not rebuilding my library dependencies.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've to do a 'clean workspace' before it picks up changes to the libraries (yes, there are set as dependencies of the main project).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;All is not solved, but I'll make a new thread for that, to keep the subject stick to the subject line....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remco Poelstra&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:00:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Problem-mixing-polling-and-interrupt-ROM-based-UART/m-p/560397#M16080</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:00:40Z</dc:date>
    </item>
  </channel>
</rss>

