<?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>UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38619/uart-adc-btle-timer-1msec</link><description>Currently working on an app which will utilize the ADC component of an NRF chip. 
 The app will use the full bluetooth stack SF132;6.0.0, adc, and will need to have ability to send uart. 
 First: I need to initialize the ADC for multiple channels and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Sep 2018 11:01:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38619/uart-adc-btle-timer-1msec" /><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149808?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 11:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a362f7b-c1d2-4236-b4e9-cb90ff751364</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I agree that the documentation need a bit of improvement. Regarding the SAADC samples, you do not need to do any data manipulation other than adjust for the gain. However, you need to make sure that you set an acquisition time that is appropriate for your source (not too short if you have a high source resistance). You can refer to the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=2_1_0_36_11#unique_397560666"&gt;SAADC electrical specification&lt;/a&gt; for details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149663?ContentTypeID=1</link><pubDate>Thu, 20 Sep 2018 13:42:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c92e8b4d-d0d9-401b-92b1-050e9ed5ac46</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the clarification.&lt;/p&gt;
&lt;p&gt;The driver doc link points to the non-blocking mode of the SAADC configuration. However, the docs say this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To enable the low power mode, you must specify this option when initializing the driver. You can do it by setting&amp;nbsp;&lt;/span&gt;&lt;a class="el" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__nrf__drv__saadc__config.html#ga7e7da65888f2c0169a53fbf379c1e79c"&gt;SAADC_CONFIG_LP_MODE&lt;/a&gt;&lt;span&gt;&amp;nbsp;to true in the driver initialization configuration structure. When it is enabled, the driver uses less power, but more interrupts are generated. When using this mode, the parameter size of function&amp;nbsp;&lt;/span&gt;&lt;a class="el" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__nrf__drv__saadc.html#ga6df4cb98bb337d1fcd6d8cf7ff0d3670"&gt;nrf_drv_saadc_buffer_convert&lt;/a&gt;&amp;nbsp;&lt;span&gt;must be a multiple of the number of enabled channels. Otherwise, undefined behavior may occur.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which I took to mean that the multiple of input channels, was only required for LP mode.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I feel that a restructuring of that section of the docs would make this much easier to follow.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Changing it so the content clearly says &amp;quot;[If running in scan mode, the dma buffer must be a multiple of the number of input channels.]&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also I&amp;#39;m not 100% familiar with successive approximation adcs, most of the ones I have dealt with just give me a &amp;quot;raw&amp;quot; value. Can I expect the same behavior from this configuration, or do I need to do any data manipulation to convert successive dma reads?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149588?ContentTypeID=1</link><pubDate>Thu, 20 Sep 2018 09:14:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18bab4e4-4b51-414e-b745-54de2261d0a5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;When you sample multiple channels using scan mode you only need to trigger sampling once. Then all channels will be sampled, and you will get a single event in the end. At that point you know that you have a new sample for each channel. The samples for all channels are put in the same buffer, but interleaved so that if e.g.&amp;nbsp; you have two channels, then you will find the samples for channel 1 in index 0,2,.. and for channel 2 in index 1,3,... Therefor the buffer size always has to be a multiple of the number of enabled channels (see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/hardware_driver_saadc.html?cp=4_0_0_2_0_12_1_1#saadc_nonblocking"&gt;driver doc&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149516?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 20:04:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab76f23a-b9ed-4314-ad75-04175ce25b37</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;What adjustments would need to be made?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149478?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 13:53:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0992d241-383a-459a-b203-fec20ca2f6be</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;Einar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;That is a great post. My only real question left on ADC is, once all channels are initialized will the ADC read be triggered on all channels, or will I need to do some trickery in the adc handler?&lt;/p&gt;
&lt;p&gt;In addition, how will I know what channel was just read in the handler?&lt;/p&gt;
&lt;p&gt;Thanks for any help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149342?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 06:29:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fc044ea-4b2b-4c84-be22-828d8fe27f6a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;From what I understood you want to sample multiple channels at the same time, but you want to trigger each series manually. Then you set up multiple channels to use scan mode, and trigger sampling of all channels by triggering the&amp;nbsp;SAMPLE task once. This can be done from PPI (if you want a timer to do it), but as you wrote that you want to do it from the application you just have to write 1 to the SAMPLE task instead. Using the driver, this is typically done by calling nrf_drv_saadc_sample() after first calling&amp;nbsp;nrf_drv_saadc_buffer_convert(), as described in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/hardware_driver_saadc.html?cp=4_0_0_2_0_12"&gt;driver documentation&lt;/a&gt;.&amp;nbsp;(You can also test with simply using nrf_drv_saadc_sample_convert() which is a blocking call that does everything in one go, but since it is blocking this is probably not sensible in a real application).&lt;/p&gt;
&lt;p&gt;If you mean that you in your project want to sample as fast as every 100&amp;nbsp;µs, then triggering sampling from the application (CPU) every time does not seem sensible. If so, you should use PPI instead. For that, I recommend you refer to the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/nrf_dev_saadc_example.html?cp=4_0_0_4_5_33"&gt;SAADC example in the SDK&lt;/a&gt;. It only uses one channel, but it does not need much adjustment to add another.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149324?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 20:41:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93e8056f-eea5-4333-bcfa-baea699adf57</guid><dc:creator>tommy.lane</dc:creator><description>[quote userid="7377" url="~/f/nordic-q-a/38619/uart-adc-btle-timer-1msec/149239"](continuous mode)[/quote]
&lt;p&gt;Einar,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure how to setup the&amp;nbsp;PPI to do this.&lt;/p&gt;
&lt;p&gt;What would I need to interconnect to sample all registered adc channels in quick succession?&lt;/p&gt;
&lt;p&gt;And how would I trigger the event to start this off without using a task specific interrupt.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;P.S. I&amp;#39;ve recently (last two hours) been informed that the ADC sample request could happen as fast as every 100 useconds.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149323?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 20:04:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:876a697e-0ce7-44c2-8a3e-9cc2414c71f4</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;SAADC documentation:&lt;/p&gt;
&lt;p&gt;Example for setting up sampling by PPI:&lt;/p&gt;
&lt;div class="fragment"&gt;
&lt;div class="line"&gt;err_code = &lt;a class="code" title="Macro for forwarding the new implementation." href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__nrf__drv__saadc.html#ga6df4cb98bb337d1fcd6d8cf7ff0d3670"&gt;nrf_drv_saadc_buffer_convert&lt;/a&gt;(buffer, length);&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;//Check error.&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;uint32_t sample_task = &lt;a class="code" title="Macro for forwarding the new implementation." href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/group__nrf__drv__saadc.html#gaf762606bdb8f02559c003b179b088f9d"&gt;nrf_drv_saadc_sample_task_get&lt;/a&gt;();&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;//Set task end point in PPI using sample_task variable.&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;What would I use for the event end point?&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;Does this trigger the SAADC to sample all channels?&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="line"&gt;&lt;span class="comment"&gt;Thanks.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149291?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 14:59:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a501644a-e1fe-4c49-8e07-cb2dee1ccf6a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I didn&amp;#39;t quite understand your last comment, but It is probably not important. You can of course generate the tick in any way you like. (The reason I mentioned the app timer library is that it is a user friendly library that lets you reuse a RTC for multiple timers of various sorts. A &lt;em&gt;repeated&lt;/em&gt; app timer is essentially a the same as tick - you get a regular event/interrupt at a fixed (average) interval.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149288?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 14:53:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a5e14ba-278d-47be-a27b-f860b8384f24</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;Let me clarify what I meant,&amp;nbsp;we are using a library that requires a one MS interrupt. Which is what we refer to as a tick internally (pretty sure that is what it is called everywhere).&lt;/p&gt;
&lt;p&gt;While the app timers are certainly useful they do not fit well with the libraries used on this project.&lt;/p&gt;
&lt;p&gt;The ADC will be called by the library, and it will probably only run at the fastest of every 50ms.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149259?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 13:39:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56a45481-cd6b-4600-b844-4f80b383edf0</guid><dc:creator>tommy.lane</dc:creator><description>&lt;p&gt;Thanks for the info!&lt;/p&gt;
&lt;p&gt;The nrf chip will not be receiving any UART, just sending. So I believe the DMA will work out well. Thanks for the help. I&amp;#39;ll get into it today and see if this addresses my concerns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART, ADC, BTLE, Timer 1msec</title><link>https://devzone.nordicsemi.com/thread/149239?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 13:00:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31bf6799-997d-4823-b12e-db962029725f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/hardware_driver_saadc.html?cp=4_0_0_2_0_12"&gt;SAADC driver documentation&lt;/a&gt; describes how you can trigger ADC sampling. Note that you have to trigger it via PPI if you want to sample all channels in quick succession (continuous mode), but you can still sample each channel only once per time it is triggered (see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=2_1_0_36_4_3#saadc_operationmodes_scan"&gt;Scan mode&lt;/a&gt;). The most sensible way to trigger sampling every 1 ms is probably using the application timer (See &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_timer.html?cp=4_0_0_3_51"&gt;timer library documentation&lt;/a&gt;). The SDK does not have any example that shows exactly this, but Jørgen has attached a project (zip file) to this post, which regularly samples two channels to &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20895/saadc-low-power-scan-mode/81591#81591"&gt;this post&lt;/a&gt;. Note that it is for an older SDK and id uses the RTC directly instead of via the timer library, but most of the example should be relevant.&lt;/p&gt;
&lt;p&gt;The nRF52 only has a single CPU, so you cannot necessarily always have the UART peripheral running while the SoftDevice is handling a BLE packet. However, the UART peripheral has DMA support, so you may not need to use the CPU that much. Moreover, you should make sure to use hardware flow control if possible so that you do not risk losing data in case the nRF is not ready to receive data when the other UART device wants to transmit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>