<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86547/please-help-me-modify-this-serial-routine-to-resolve-the-problem-of-unstable-data-sending-and-receiving</link><description>Use this routine to send and receive data from 4 different serials, receive and send data loss, please help me modify this sample bug. 
 sdk ncs v1.3 Path:D:\ncs\v1.3.0\nrf\samples\nrf9160\spm\prj.conf Filename:prj.conf Modify:CONFIG_SERIAL=n 
 Path:D</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Nov 2020 07:53:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86547/please-help-me-modify-this-serial-routine-to-resolve-the-problem-of-unstable-data-sending-and-receiving" /><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361340?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 07:53:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a43e6a2-028e-4fd7-9727-e09e885970b2</guid><dc:creator>peter.min</dc:creator><description>&lt;p&gt;Hi Håkon Hardy Lier,&lt;/p&gt;
&lt;p&gt;This issue has been resolved.&lt;br /&gt;By adding fifo to tx and rx to separate TX from RX,&lt;br /&gt;nrf9160 serial port use is very different from the nrf52 series,&lt;br /&gt;It&amp;#39;s also very different from other slings.&lt;/p&gt;
&lt;p&gt;Thank you for all your assistance.&lt;br /&gt;Kind regards,&lt;br /&gt;Peter.Min&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361339?ContentTypeID=1</link><pubDate>Mon, 16 Nov 2020 13:28:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be8aa01b-4c5f-4cf1-a104-90774912a7a6</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Do you know if the bug is reproducible with three uarts? I don&amp;#39;t have another USB to TTL serial cable at the moment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361338?ContentTypeID=1</link><pubDate>Fri, 13 Nov 2020 15:26:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:916a37c1-71a5-4d2e-a617-f786be656667</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;I have a similar cable so I will probably be able to reproduce this today or on Monday.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361337?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 02:19:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e7fc44-e20f-4acc-891b-10e3bfe6ed11</guid><dc:creator>peter.min</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Hi Håkon Hardy Lier,&lt;/p&gt;
&lt;p&gt;I have a USB-to-TTL serial tool on hand to verify&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Peter.Min&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361336?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 12:48:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14d2d45c-58f6-4955-a1d5-36b6c359e5b4</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;How do you test all four uarts at once? The nrf9160 has three VCOM ports, so how do you test the last uart?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361335?ContentTypeID=1</link><pubDate>Wed, 04 Nov 2020 09:58:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77f9ff83-462f-43e0-b2c7-05a7649f15ac</guid><dc:creator>peter.min</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Håkon Hardy Lier,&lt;/p&gt;
&lt;p&gt;I try to use multiple bufs&lt;br /&gt;The test results are still consistent with the original phenomenon&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*

* Copyright (c) 2012-2014 Wind River Systems, Inc.

*

* SPDX-License-Identifier: Apache-2.0

*/
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;drivers/uart.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;logging/log.h&amp;gt;
LOG_MODULE_REGISTER(uart, 3);

static u8_t uart_buf[4][256];
struct device *uart0 = NULL;
struct device *uart1 = NULL;
struct device *uart2 = NULL;
struct device *uart3 = NULL;

void uart0_cb(struct device *x)
{
    uart_irq_update(x);
    int data_length = 0;
    
    if (uart_irq_rx_ready(x)) 
    {
        data_length = uart_fifo_read(x, uart_buf[0], sizeof(uart_buf[0]));
        uart_buf[0][data_length] = 0;
        uart_fifo_fill( x, uart_buf[0], strlen(uart_buf[0]) );
    }
}

void uart1_cb(struct device *x)
{
    uart_irq_update(x);
    int data_length = 0;
    
    if (uart_irq_rx_ready(x)) 
    {
        data_length = uart_fifo_read(x, uart_buf[1], sizeof(uart_buf[1]));
        uart_buf[1][data_length] = 0;
        uart_fifo_fill( x, uart_buf[1], strlen(uart_buf[1]) );
    }
}

void uart2_cb(struct device *x)
{
    uart_irq_update(x);
    int data_length = 0;
    
    if (uart_irq_rx_ready(x)) 
    {
        data_length = uart_fifo_read(x, uart_buf[2], sizeof(uart_buf[2]));
        uart_buf[2][data_length] = 0;
        uart_fifo_fill( x, uart_buf[2], strlen(uart_buf[2]) );
    }
}

void uart3_cb(struct device *x)
{
    uart_irq_update(x);
    int data_length = 0;
    
    if (uart_irq_rx_ready(x)) 
    {
        data_length = uart_fifo_read(x, uart_buf[3], sizeof(uart_buf[3]));
        uart_buf[3][data_length] = 0;
        uart_fifo_fill( x, uart_buf[3], strlen(uart_buf[3]) );
    }
}

void main(void)
{
    uart0 = device_get_binding(&amp;quot;UART_0&amp;quot;);
    uart1 = device_get_binding(&amp;quot;UART_1&amp;quot;);
    uart2 = device_get_binding(&amp;quot;UART_2&amp;quot;);
    uart3 = device_get_binding(&amp;quot;UART_3&amp;quot;);

    uart_irq_callback_set(uart0, uart0_cb);
    uart_irq_rx_enable(uart0);
    
    uart_irq_callback_set(uart1, uart1_cb);
    uart_irq_rx_enable(uart1);
    
    uart_irq_callback_set(uart2, uart2_cb);
    uart_irq_rx_enable(uart2);

    uart_irq_callback_set(uart3, uart3_cb);
    uart_irq_rx_enable(uart3);
    
    LOG_INF(&amp;quot;uart init&amp;quot;);
    while (1) 
    {
        //k_cpu_idle();
        LOG_INF(&amp;quot;Hello World!\n&amp;quot;);
        k_sleep( Z_TIMEOUT_MS(8000) );
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Kind regards. Peter.Min&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361334?ContentTypeID=1</link><pubDate>Tue, 03 Nov 2020 13:24:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:428bdbc4-8937-44e2-abf2-cc49ea7b2751</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;In main.c you are using uart_buf for all the uart instances. Have you tried using a separate buffer for each of them?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361333?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 14:13:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c44e4e4f-a436-43b1-916b-1e345f5951c2</guid><dc:creator>peter.min</dc:creator><description>&lt;p&gt;Hi HåkonHardy Lier,&lt;/p&gt;
&lt;p&gt;1. Have you ever tested your serial communication?&lt;br /&gt;2.Can you test the code I gave you?&lt;br /&gt;3. Is this kind of error easy to encounter?&lt;br /&gt;4. The most common errors are as follows:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/6320.0-_0E663E66324EE3531995EF8B_.png" /&gt;&lt;/p&gt;
&lt;p&gt;Kind regards. Peter.Min&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please help me modify this serial routine to resolve the problem of unstable data sending and receiving.</title><link>https://devzone.nordicsemi.com/thread/361332?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 13:09:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:345dd9b2-8960-47f5-9870-d1b381aa356c</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;can you describe the problem you&amp;#39;re experiencing? What do you mean by unstable data sending and receiving?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>