<?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>Help with basic implementation of UART</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89018/help-with-basic-implementation-of-uart</link><description>Hello, 
 
 I am working on developing a BLE peripheral FW (Reader) with NRF52840 using nRF Connect SDK 2.0.0. The Reader has two MCU, one is BLE MCU and other is the main Control MCU. 
 I have implemented my custom BLE service in the BLE FW. 
 Some data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Jun 2022 13:15:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89018/help-with-basic-implementation-of-uart" /><item><title>RE: Help with basic implementation of UART</title><link>https://devzone.nordicsemi.com/thread/373258?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 13:15:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e734914-b417-4c1e-8b63-a43f9924c688</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello again Deep, I hope you&amp;#39;ve had a nice weekend.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When it comes to what to start with you could for instance base your BLE MCU on the central_uart sample.&amp;nbsp;To get an&amp;nbsp;understanding of the sample and UART API I would generally recommend the DevAcademy and&amp;nbsp;the sample documentation, though you can of course ask here as well.&lt;/p&gt;
&lt;p&gt;Have you gotten any further since last week?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Help with basic implementation of UART</title><link>https://devzone.nordicsemi.com/thread/373083?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 15:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb0bce6-cfbe-45bb-bc7d-dd783e637c86</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello Deep,&lt;/p&gt;
&lt;p&gt;Unfortunately I will have to get back to you on this next week.&lt;/p&gt;
&lt;p&gt;Though note that we have several examples on UART ( &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/peripheral/lpuart/README.html"&gt;Low power uart&lt;/a&gt;, &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html?highlight=uart"&gt;peripheral uart&lt;/a&gt;, and &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/central_uart/README.html?highlight=uart"&gt;central uart&lt;/a&gt;), as well as a &lt;a href="https://academy.nordicsemi.com/topic/uart-protocol/"&gt;section on UART in our DevAcademy&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Help with basic implementation of UART</title><link>https://devzone.nordicsemi.com/thread/372890?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2022 22:12:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3da11ae7-98b1-465c-8658-982eea43f584</guid><dc:creator>Deep Patel</dc:creator><description>&lt;p&gt;Hello .. any help ? I need to get this to work asap.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have reference from peripheral_lpuart example and use it in my project as :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;LOG_MODULE_REGISTER(uart);

const struct device *lpuart = DEVICE_DT_GET(DT_NODELABEL(lpuart));

int uart_init(void)
{
	if (!device_is_ready(lpuart)) 
	{
		printk(&amp;quot;LPUART device not ready\n&amp;quot;);
		return -ENODEV;
	}

	uart_irq_callback_user_data_set(lpuart, uart_irq_handler, NULL);

	uart_irq_rx_enable(lpuart);

	while (1) 
	{
		uart_irq_tx_enable(lpuart);
		k_sleep(K_MSEC(500));

		uart_poll_out(lpuart, 0xff);
		k_sleep(K_MSEC(100));
	}
}

static void uart_irq_handler(const struct device *dev, void *context)
{
	uint8_t buf[] = {1, 2, 3, 4, 5};

	if (uart_irq_tx_ready(dev)) 
	{
		(void)uart_fifo_fill(dev, buf, sizeof(buf));
		uart_irq_tx_disable(dev);
	}

	if (uart_irq_rx_ready(dev)) 
	{
		uint8_t buf[10];
		int len = uart_fifo_read(dev, buf, sizeof(buf));

		if (len) 
		{
			printk(&amp;quot;read %d bytes\n&amp;quot;, len);
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am not able to understand how do i use it ? Can you explain .. the flow of these UART API and Tx and Rx. What triggers what ?&lt;/p&gt;
&lt;p&gt;I have used interrupt based uart.&lt;/p&gt;
&lt;p&gt;I have my high level Application functions: Datalnit, SendData and ReceiveData in nRF52840 code to be used for UART.&lt;/p&gt;
&lt;p&gt;uart_init i am calling inside DataInit.&lt;/p&gt;
&lt;p&gt;What shall i write inside&amp;nbsp;&lt;span&gt;SendData and ReceiveData from uart code i posted.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>