<?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>Low level driver implementation without Zephyr on nRF Connect SDK / How to get UARTE running</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96877/low-level-driver-implementation-without-zephyr-on-nrf-connect-sdk-how-to-get-uarte-running</link><description>Hi, 
 I&amp;#39;ve been working with the nRF5x SDK for many years and happily implemented low level drivers on register level, sometimes also using the nrf_drv drivers, running FreeRTOS and using a simple makefile build system. 
 Now I need to port one project</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Mar 2023 09:25:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96877/low-level-driver-implementation-without-zephyr-on-nrf-connect-sdk-how-to-get-uarte-running" /><item><title>RE: Low level driver implementation without Zephyr on nRF Connect SDK / How to get UARTE running</title><link>https://devzone.nordicsemi.com/thread/412673?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 09:25:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b52f7497-d992-419e-a549-36fec36eaf36</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Michael,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m glad to hear that you got things working!&lt;/p&gt;
[quote user="puz_md"]I guess there will be no way around these zephyr based custom board definitions ;) I&amp;#39;ll make some time to get more familiar with them. It&amp;#39;s a bit confusing with all the abstraction layers and files that override other files, and I couldn&amp;#39;t find a direct link to the syntax for these descriptions, but I&amp;#39;ll watch some more tutorials and give it a try.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, this is true. The kernel will declare the interrupt handlers, which then requires you to use the API that it provides for these.&lt;/p&gt;
&lt;p&gt;Note that you can also use IRQ_DIRECT_CONNECT for higher realtime requirements:&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/3.2.0/kernel/services/interrupts.html#defining-a-direct-isr"&gt;https://docs.zephyrproject.org/3.2.0/kernel/services/interrupts.html#defining-a-direct-isr&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We use this for anything that includes RADIO peripheral, as protocol handling normally requires tighter timing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low level driver implementation without Zephyr on nRF Connect SDK / How to get UARTE running</title><link>https://devzone.nordicsemi.com/thread/412601?ContentTypeID=1</link><pubDate>Tue, 28 Feb 2023 18:54:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:938e85c6-7a5a-4d5d-b893-dd97c71614f6</guid><dc:creator>puz_md</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon,&lt;br /&gt;&lt;br /&gt;thank you very much for the detailed reply, especially for the hint about zephyr interrupt handling. I&amp;#39;ll look into this later.&lt;br /&gt;&lt;br /&gt;I guess there will be no way around these zephyr based custom board definitions ;) I&amp;#39;ll make some time to get more familiar with them. It&amp;#39;s a bit confusing with all the abstraction layers and files that override other files, and I couldn&amp;#39;t find a direct link to the syntax for these descriptions, but I&amp;#39;ll watch some more tutorials and give it a try.&lt;br /&gt;&lt;br /&gt;And sorry for getting the ENABLE value wrong... I must have overlooked this as the events and tasks usually work with &amp;quot;1&amp;quot;, so I missed that there are multiple bits defined for ENABLE in the product specification. With this fixed, I got my sample code running.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low level driver implementation without Zephyr on nRF Connect SDK / How to get UARTE running</title><link>https://devzone.nordicsemi.com/thread/411029?ContentTypeID=1</link><pubDate>Tue, 21 Feb 2023 08:36:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:894ce549-aa60-43e2-b2d3-d51c0d1fd711</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;Now I need to port one project to the nRF5340, which means moving on to the nRF Connect SDK, and life has become hell. I don&amp;#39;t mind using Zephyr for IPC and Bluetooth related topics, but I need full control over my device drivers as they sometimes implement critical features with hard real-time constraints. There are also scenarios where I need to connect different drivers via the PPI and handle low latency interrupts.&lt;/p&gt;
&lt;p&gt;Developing software with Visual Studio Code and the Nordic plugin is really exhausting. Even though the plugin should have installed the necessary addons, VS Code asks me each time I start it if I want to install the plugins that should be already there (like Git and C++). Also, errors pop up and disappear all the time. And VS Code suddelny switches to other projects and/or build targets without any notice. But well, the most critical part is that I cannot get my device drivers running properly anymore.&lt;/p&gt;[/quote]
&lt;p&gt;I fully understand your situation and I apologize for the rough path to getting your setup up and running.&lt;/p&gt;
&lt;p&gt;If you end up implementing low-level functionality directly, be aware of how zephyr kernel wraps the interrupt vectors. Here&amp;#39;s an example on how to enable a given ISR vector:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.zephyrproject.org/3.2.0/kernel/services/interrupts.html#defining-a-regular-isr"&gt;https://docs.zephyrproject.org/3.2.0/kernel/services/interrupts.html#defining-a-regular-isr&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user=""]One example: I started a new project based on zephyr/samples/basic/threads, using the nRF5340DK as a build target. There, I wanted to get the UARTE2 device running. But it is really difficult, I had problems using the nrfx_uarte driver as it didn&amp;#39;t find UARTE2 even though I tried to enable it in proj.conf (&amp;quot;CONFIG_NRFX_UARTE2=y&amp;quot; did not work). I have lost a whole week already, and so I decided to go down to register level and implement my own UARTE driver (as I will need to add special low latency handling later anyway). But I still can&amp;#39;t get the UARTE interface running on low level.[/quote]
&lt;p&gt;Recently we added&amp;nbsp;nrfx samples in the repository:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_uarte"&gt;https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_uarte&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can use these if you want to use any of the nrfx drivers directly in&amp;nbsp;NCS.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]1. How can I get full access to the hardware devices while Zephyr is running on the background? Just including &amp;lt;nrf.h&amp;gt; or &amp;lt;nrf5340_application.h&amp;gt; does not help. To get the definitions for the UARTE2 device, I have to include &amp;lt;nrfx_uarte.h&amp;gt;. One more issue is that the UARTE device does not seem to work as expected, which brings me to my second question:[/quote]
&lt;p&gt;You can include &amp;lt;nrf.h&amp;gt; directly. This shall include the&amp;nbsp;correct device, based on the board that you compile for.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]2. If I execute the following initialization code which should start receiving UART data, the TASKS_STARTRX task does not trigger an EVENTS_RXSTARTED event as expected. The device registers are initialized correctly as I can see in the VS Code plugin during debugging, but the event is not set. I observe similiar behavior when I try to transmit data instead of receiving (set the TXD buffer and size, trigger TASKS_STARTTX and wit for EVENTS_TXSTARTED which never appears. What could be the reason for this?[/quote]
&lt;p&gt;When writing on bare metal level, I recommend that you use the defines from nrf*_bitfields.h, to ensure that you&amp;#39;re setting the correct bit in the register:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_UARTE2-&amp;gt;ENABLE = UARTE_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; UARTE_ENABLE_ENABLE_Pos;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I see that you have used these defines for most of your setup, but it looks like the ENABLE register is set to the incorrect value in your code snippet.&lt;/p&gt;
&lt;p&gt;.ENABLE for bus peripherals are not &amp;#39;1&amp;#39;. The reasoning behind this is that the hardware peripheral itself can be setup in UART/SPI*/TWI* mode under-the-hood.&lt;/p&gt;
&lt;p&gt;example: NRF_UARTEx-&amp;gt;ENABLE is &amp;#39;8&amp;#39;, while NRF_SPIMx-&amp;gt;ENABLE is &amp;#39;7&amp;#39;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>