<?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 mpc5748g lwip&amp;amp; uart in MPC5xxx</title>
    <link>https://community.nxp.com/t5/MPC5xxx/mpc5748g-lwip-amp-uart/m-p/1201665#M16894</link>
    <description>&lt;P&gt;您好，我使用的是MPC5748G。&lt;/P&gt;&lt;P&gt;我在软件提供的例子“lwip”上添加了uart通信，实现通过UDP接收然后通过Uart传出数据。一开始发送数据后，Uart有返回数据，等成功的运行了20分钟左右，程序突然断开，且再启动后无法通过Uart返回数据，rebuild后也无法实现。以下是我在lwip例子中添加的uart的配置和代码：&lt;/P&gt;&lt;P&gt;uart组件配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uart组件配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133032i4B6CDA184A97A4F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uart组件配置.png" alt="uart组件配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;uart引脚配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uart引脚配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133033i6E1984450C5FF49E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uart引脚配置.png" alt="uart引脚配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;时钟配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="时钟配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133034iCD60A7F47EC2AAFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="时钟配置.png" alt="时钟配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;代码补全（udpecho.c）：&lt;/P&gt;&lt;P&gt;/*-----lixu------------------------------------------------------------------------------*/&lt;BR /&gt;#define TIMEOUT 100UL&lt;BR /&gt;#define BUFFER_SIZE 256UL&lt;BR /&gt;//uint8_t buff[BUFFER_SIZE];&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; &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; &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; uint8_t bufferIdx;&lt;/P&gt;&lt;P&gt;void uartRxCallback(void *driverState, uart_event_t event, void *userData) {&lt;BR /&gt;&amp;nbsp; /* Unused parameters */&lt;BR /&gt;&amp;nbsp; (void)driverState;&lt;BR /&gt;&amp;nbsp; (void)userData;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Check the event type */&lt;BR /&gt;&amp;nbsp; if (event == UART_EVENT_RX_FULL)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; /* The reception stops when newline is received or the buffer is full */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if ((buffer[bufferIdx] != '\n') &amp;amp;&amp;amp; (bufferIdx != (BUFFER_SIZE - 2U)))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* Update the buffer index and the rx buffer */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; bufferIdx++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; UART_SetRxBuffer(&amp;amp;uart_pal1_instance, &amp;amp;buffer[bufferIdx], 1U);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;/*-----------------------------------------------------------------------------------*/&lt;/P&gt;&lt;P&gt;udpecho_thread( )下添加&lt;/P&gt;&lt;P&gt;/* Initialize UART PAL over LINFlexD */&lt;BR /&gt;UART_Init(&amp;amp;uart_pal1_instance, &amp;amp;uart_pal1_Config0);&lt;/P&gt;&lt;P&gt;/* Send the received data back */&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UART_SendDataBlocking(&amp;amp;uart_pal1_instance, buffer, strlen((char *)buffer), TIMEOUT);&lt;/P&gt;&lt;P&gt;错误现象：&lt;/P&gt;&lt;P&gt;运行工程，使用网络传输助手发送数据，uart和udp都没有接收到数据（原来例子中的udp发送没有关掉，所以发送数据时udp和uart应该都可以返回数据），程序断开。&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="程序断开.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133037i33E13EF091A2BE8A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="程序断开.png" alt="程序断开.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;另一现象：&lt;/P&gt;&lt;P&gt;当注释掉UART_SendDataBlocking( ）函数时，udp可以返回数据。&lt;/P&gt;&lt;P&gt;想请教一下大家有没有知道这个问题的原因及解决方法。&lt;/P&gt;&lt;P&gt;望回复，谢谢！&lt;/P&gt;</description>
    <pubDate>Fri, 18 Dec 2020 08:07:47 GMT</pubDate>
    <dc:creator>lixu</dc:creator>
    <dc:date>2020-12-18T08:07:47Z</dc:date>
    <item>
      <title>mpc5748g lwip&amp; uart</title>
      <link>https://community.nxp.com/t5/MPC5xxx/mpc5748g-lwip-amp-uart/m-p/1201665#M16894</link>
      <description>&lt;P&gt;您好，我使用的是MPC5748G。&lt;/P&gt;&lt;P&gt;我在软件提供的例子“lwip”上添加了uart通信，实现通过UDP接收然后通过Uart传出数据。一开始发送数据后，Uart有返回数据，等成功的运行了20分钟左右，程序突然断开，且再启动后无法通过Uart返回数据，rebuild后也无法实现。以下是我在lwip例子中添加的uart的配置和代码：&lt;/P&gt;&lt;P&gt;uart组件配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uart组件配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133032i4B6CDA184A97A4F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uart组件配置.png" alt="uart组件配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;uart引脚配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="uart引脚配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133033i6E1984450C5FF49E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="uart引脚配置.png" alt="uart引脚配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;时钟配置：&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="时钟配置.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133034iCD60A7F47EC2AAFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="时钟配置.png" alt="时钟配置.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;代码补全（udpecho.c）：&lt;/P&gt;&lt;P&gt;/*-----lixu------------------------------------------------------------------------------*/&lt;BR /&gt;#define TIMEOUT 100UL&lt;BR /&gt;#define BUFFER_SIZE 256UL&lt;BR /&gt;//uint8_t buff[BUFFER_SIZE];&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; &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; &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; uint8_t bufferIdx;&lt;/P&gt;&lt;P&gt;void uartRxCallback(void *driverState, uart_event_t event, void *userData) {&lt;BR /&gt;&amp;nbsp; /* Unused parameters */&lt;BR /&gt;&amp;nbsp; (void)driverState;&lt;BR /&gt;&amp;nbsp; (void)userData;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Check the event type */&lt;BR /&gt;&amp;nbsp; if (event == UART_EVENT_RX_FULL)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; /* The reception stops when newline is received or the buffer is full */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if ((buffer[bufferIdx] != '\n') &amp;amp;&amp;amp; (bufferIdx != (BUFFER_SIZE - 2U)))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* Update the buffer index and the rx buffer */&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; bufferIdx++;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; UART_SetRxBuffer(&amp;amp;uart_pal1_instance, &amp;amp;buffer[bufferIdx], 1U);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;/*-----------------------------------------------------------------------------------*/&lt;/P&gt;&lt;P&gt;udpecho_thread( )下添加&lt;/P&gt;&lt;P&gt;/* Initialize UART PAL over LINFlexD */&lt;BR /&gt;UART_Init(&amp;amp;uart_pal1_instance, &amp;amp;uart_pal1_Config0);&lt;/P&gt;&lt;P&gt;/* Send the received data back */&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UART_SendDataBlocking(&amp;amp;uart_pal1_instance, buffer, strlen((char *)buffer), TIMEOUT);&lt;/P&gt;&lt;P&gt;错误现象：&lt;/P&gt;&lt;P&gt;运行工程，使用网络传输助手发送数据，uart和udp都没有接收到数据（原来例子中的udp发送没有关掉，所以发送数据时udp和uart应该都可以返回数据），程序断开。&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="程序断开.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133037i33E13EF091A2BE8A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="程序断开.png" alt="程序断开.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;另一现象：&lt;/P&gt;&lt;P&gt;当注释掉UART_SendDataBlocking( ）函数时，udp可以返回数据。&lt;/P&gt;&lt;P&gt;想请教一下大家有没有知道这个问题的原因及解决方法。&lt;/P&gt;&lt;P&gt;望回复，谢谢！&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 08:07:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/mpc5748g-lwip-amp-uart/m-p/1201665#M16894</guid>
      <dc:creator>lixu</dc:creator>
      <dc:date>2020-12-18T08:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: mpc5748g lwip&amp; uart</title>
      <link>https://community.nxp.com/t5/MPC5xxx/mpc5748g-lwip-amp-uart/m-p/1202676#M16914</link>
      <description>&lt;P&gt;此问题已解决，找到问题错误出现在哪里。可以进行通信，但是uart转发数据总是丢第二位，有待解决，望有经验者指点一下。&lt;/P&gt;</description>
      <pubDate>Tue, 22 Dec 2020 01:34:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/mpc5748g-lwip-amp-uart/m-p/1202676#M16914</guid>
      <dc:creator>lixu</dc:creator>
      <dc:date>2020-12-22T01:34:10Z</dc:date>
    </item>
  </channel>
</rss>

