<?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>nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80345/nrf52840-uarte-in-zephyr</link><description>I&amp;#39;m having problems using the UARTE in the nRF52840 via Zephyr. I&amp;#39;m watching the TX pin using a logic analyzer and seeing correct data when running at 9600 baud. But if I configure the UART for 115200 baud, the data is garbled (sometimes some later characters</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Oct 2021 06:52:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80345/nrf52840-uarte-in-zephyr" /><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333628?ContentTypeID=1</link><pubDate>Tue, 12 Oct 2021 06:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5240ba6f-88ec-4ec9-86e5-942cd14be91d</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="CktDesigner"]Q1 answer: Yes.&amp;nbsp; I start the logic analyzer capture, then start the code, capturing the entire sequence, then stop the logic analyzer and zoom into the UART transaction.&amp;nbsp; &amp;nbsp;This is the first (only) transaction.&amp;nbsp; &amp;nbsp;I substituted the normal control sequence that should be sent for a simple letter sequence to help see the results on the logic analyzer.[/quote]
&lt;p&gt;Jitters during, and straight after reset is to be expected, as the line is undefined prior to the firmware setting it. You can add a pull-up resistor on the line if you&amp;#39;d like.&lt;/p&gt;
[quote user="CktDesigner"]Q2 answer: There is a receiver attached.&amp;nbsp; The UART is connected to a Sierra Wireless XA1110 GPS module.&amp;nbsp; &amp;nbsp;The module is delivered preconfigured to run at 115200 baud, so communication must be at that speed to configure anything (including changing the baud rate).&amp;nbsp; The two connections (TX_UART and RX_UART) are point-to-point and shown in the following images.&amp;nbsp; &amp;nbsp;They are both only about 35 mm in length.&amp;nbsp; &amp;nbsp;(The rectangular pads near the center of the trace are for clip points to attach the logic analyzer.)&amp;nbsp; I thought that perhaps this was a &amp;quot;transmission line&amp;quot; issue, but if that was the case, I would expect all edges to be affected, not just the ones in the first couple of characters.&amp;nbsp; &amp;nbsp;Here are highlights of the two nets:[/quote]
&lt;p&gt;As you mention, if the issue is only in the startup sequence, the issue is not purely electrical in the sense that capacitance etc. is causing this. I believe it is related to the GPIO state when the nRF is in reset and starting up. Could you try to add a pull-up resistor on the line to see if this helps?&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><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333585?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 17:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b531c76f-7f66-4e18-976c-1ce67b0a8f7c</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;Yes, that is what I meant by shifting causing decoding issues...&lt;/p&gt;
&lt;p&gt;Q1 answer: Yes.&amp;nbsp; I start the logic analyzer capture, then start the code, capturing the entire sequence, then stop the logic analyzer and zoom into the UART transaction.&amp;nbsp; &amp;nbsp;This is the first (only) transaction.&amp;nbsp; &amp;nbsp;I substituted the normal control sequence that should be sent for a simple letter sequence to help see the results on the logic analyzer.&lt;/p&gt;
&lt;p&gt;Q2 answer: There is a receiver attached.&amp;nbsp; The UART is connected to a Sierra Wireless XA1110 GPS module.&amp;nbsp; &amp;nbsp;The module is delivered preconfigured to run at 115200 baud, so communication must be at that speed to configure anything (including changing the baud rate).&amp;nbsp; The two connections (TX_UART and RX_UART) are point-to-point and shown in the following images.&amp;nbsp; &amp;nbsp;They are both only about 35 mm in length.&amp;nbsp; &amp;nbsp;(The rectangular pads near the center of the trace are for clip points to attach the logic analyzer.)&amp;nbsp; I thought that perhaps this was a &amp;quot;transmission line&amp;quot; issue, but if that was the case, I would expect all edges to be affected, not just the ones in the first couple of characters.&amp;nbsp; &amp;nbsp;Here are highlights of the two nets:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/UART_5F00_RX_5F00_net.JPG" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/UART_5F00_TX_5F00_net.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;The Laird module is on the right side;&amp;nbsp; the XA1110 is at the bottom left.&lt;/p&gt;
&lt;p&gt;Thanks...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333381?ContentTypeID=1</link><pubDate>Mon, 11 Oct 2021 06:58:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4b24520-a1bf-4a0b-8fb9-cdfeca39c62c</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;
&lt;p&gt;As the waveform has jittering, the parser is parsing at the incorrect edge.&lt;/p&gt;
&lt;p&gt;Q1: is this scope taken from reset state?&lt;/p&gt;
&lt;p&gt;Q2: Do you see the same issue if you connect a receiver on the other end?&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><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333331?ContentTypeID=1</link><pubDate>Sat, 09 Oct 2021 01:18:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:364386f9-0fae-41e0-b5a4-719d6f9e1c5c</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;I&amp;#39;m using a custom board with a Laird BL654PA module.&amp;nbsp; The Laird module includes the main crystal and I have a 32.768 KHz crystal on the board (since it states in the spec that BLE works better using the crystal).&lt;/p&gt;
&lt;p&gt;So if I use the clock_init() function you suggested, do I still need the&amp;nbsp;&lt;span&gt;mpsl_clock_hfclk_request() function to keep the HFCLK on (when using BLE)?&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I also tried &amp;quot;not enabling&amp;quot; BLE (but using the clock_init() function you provided), thinking that perhaps BLE was somehow disabling the XO version of HFCLK, just to see if that made a difference, but got the same results.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is the expected waveform from my test (just a sequence of characters) when:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;current-speed = &amp;lt;9600&amp;gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;is in the board&amp;#39;s .dts file&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Baud_5F00_9600.JPG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Using the same code, but recompiling with:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;current-speed = &amp;lt;115200&amp;gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;in the board&amp;#39;s .dts file, I get this output:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Baud_5F00_115200.JPG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note that the overall shape of the two waves is very similar.&amp;nbsp; &amp;nbsp;The beginning (first character) of the 115200 baud version looks a bit corrupted, which then (I&amp;#39;m guessing) shifts all of the other characters out, causing framing errors or bad decoding.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;By zooming in appropriately and lining up the two waveforms, it appears that the 115200 baud version doesn&amp;#39;t start properly.&amp;nbsp; &amp;nbsp; Could this be a problem with the UART or the clock?&amp;nbsp; &amp;nbsp;After the first couple of characters, the waves track each other pretty closely, but since everything gets shifted the decoding fails.&amp;nbsp; &amp;nbsp;Here is the beginning of the two waves, zoomed and lined up:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/baud_5F00_comparison.JPG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Still trying to figure out what is happening...&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><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333213?ContentTypeID=1</link><pubDate>Fri, 08 Oct 2021 09:16:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b4d453e-9bb9-4d16-b874-922ce7984f12</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="CktDesigner"]Would I be better off using the nrfx uarte driver from nrfxlib (versus the Zephyr built-in UART driver)?&amp;nbsp; &amp;nbsp;Or are they the same?[/quote]
&lt;p&gt;The zephyr built-in driver is built on nrfx, so they&amp;#39;re quite similar in what&amp;#39;s underneath.&lt;/p&gt;
[quote user="CktDesigner"]I see in case ID 205318, a comment that turning on BLE might automatically switch the HFCLK to the internal oscillator to save power, and that a call to&amp;nbsp;&lt;span&gt;sd_clock_hfclk_request() is needed to ensure the HFCLK is kept with the crystal.&amp;nbsp; &amp;nbsp;Is this also true when using BLE in Zephyr?&amp;nbsp; &amp;nbsp;If so, is there an equivalent call in the Zephyr BLE API (the bt_ functions vs. the sd_ functions)?&lt;/span&gt;[/quote]
&lt;p&gt;If you are using the softdevice controller (default for all bluetooth samples in NCS), you should use this function call to request the HFCLK:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrfxlib/blob/v1.7.0/mpsl/include/mpsl_clock.h#L136"&gt;https://github.com/nrfconnect/sdk-nrfxlib/blob/v1.7.0/mpsl/include/mpsl_clock.h#L136&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For all other subsystems in zephyr (including the zephyr bluetooth link layer), the former clock_control function&amp;nbsp;will work.&lt;/p&gt;
[quote user="CktDesigner"]Is there anything else that could be happening here?[/quote]
&lt;p&gt;Could you show an example of the expected vs. corrupted output? Are you using a nRF5 DK or a external uart bridge?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/333145?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2021 22:57:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46d91b62-655b-46bf-8181-c8dcebd1a873</guid><dc:creator>CktDesigner</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for your response.&lt;/p&gt;
&lt;p&gt;I tried using the clock_init() function you highlighted in the link you provided.&amp;nbsp; &amp;nbsp; &amp;nbsp;It did not solve the problem I am seeing (logic analyzer (using async analyzer/decoder) sees correct output sequence when UART is set to 9600 (via .dts file setting), but characters are wrong when the .dts file is changed to 115200).&lt;/p&gt;
&lt;p&gt;err is reported as 0 (I assume that means everything is OK).&lt;/p&gt;
&lt;p&gt;Would I be better off using the nrfx uarte driver from nrfxlib (versus the Zephyr built-in UART driver)?&amp;nbsp; &amp;nbsp;Or are they the same?&lt;/p&gt;
&lt;p&gt;Is there anything else that could be happening here?&lt;/p&gt;
&lt;p&gt;I see in case ID 205318, a comment that turning on BLE might automatically switch the HFCLK to the internal oscillator to save power, and that a call to&amp;nbsp;&lt;span&gt;sd_clock_hfclk_request() is needed to ensure the HFCLK is kept with the crystal.&amp;nbsp; &amp;nbsp;Is this also true when using BLE in Zephyr?&amp;nbsp; &amp;nbsp;If so, is there an equivalent call in the Zephyr BLE API (the bt_ functions vs. the sd_ functions)?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 UARTE in Zephyr</title><link>https://devzone.nordicsemi.com/thread/332757?ContentTypeID=1</link><pubDate>Wed, 06 Oct 2021 08:37:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79b631cd-1411-4b84-8f35-14a988aad67a</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=""] I&amp;#39;m watching the TX pin using a logic analyzer and seeing correct data when running at 9600 baud.&amp;nbsp; &amp;nbsp;But if I configure the UART for 115200 baud, the data is garbled (sometimes some later characters are correct).&amp;nbsp; &amp;nbsp;I&amp;#39;ve tried using the &amp;quot;built-in&amp;quot; Zephyr UART driver and disabling it and using the nrfxlib uarte driver with the same results.[/quote]
&lt;p&gt;Your current configuration sets the LFCLK, while the UART&amp;#39;s tolerance comes from the HFCLK.&lt;/p&gt;
&lt;p&gt;If you are running with the internal 64M RC oscillator, it is quite inaccurate (in the percent area). You can&amp;nbsp;request the HFXO using this sequence:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/bluetooth/direct_test_mode/src/dtm.c#L497-L527"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v1.7.0/samples/bluetooth/direct_test_mode/src/dtm.c#L497-L527&lt;/a&gt;&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>