<?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>Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19934/simple-analog-read-on-nrf52</link><description>Hello. How i can do a simple read an 0 -&amp;gt; 3 Volt (vdd) signal on Analog 0 P0.03?
I try it with saadc without sucess 
 int result = 0;
 
 NRF_SAADC-&amp;gt;CH[0].CONFIG = (
 SAADC_CH_PSELN_PSELN_AnalogInput0 &amp;lt;&amp;lt; SAADC_CH_CONFIG_BURST_Pos |
 SAADC_CH_CONFIG_BURST_Enabled</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jul 2019 13:12:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19934/simple-analog-read-on-nrf52" /><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/200072?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 13:12:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49265899-13ff-405e-8337-cf03e8249aaa</guid><dc:creator>BelvitaSoft</dc:creator><description>&lt;p&gt;&lt;span&gt;Ok, I also solved the problem. Pin Analog A0 is defined as P02 on the development kit, although on the bottom of the board is written that pin P3 in A0. I changed the connection and it works.&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/200024?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 11:33:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6259bd33-2b96-47e8-b02f-8a51d24789ae</guid><dc:creator>BelvitaSoft</dc:creator><description>&lt;p&gt;Hi guys, I have the same problem - I got zero when I try to print the variable precise_result. I measure a pin 3 (A0) with voltage divider that output voltage is equal to 2.7 V. It is also confused for me that it is printed only twice, although it is in while loop.&lt;/p&gt;
&lt;p&gt;Any advice about solving this problem? &lt;a href="https://devzone.nordicsemi.com/members/rabe"&gt;Rabe&lt;/a&gt; &lt;a href="https://devzone.nordicsemi.com/members/jorgen"&gt;Jørgen&lt;/a&gt; @restoftheworld&lt;/p&gt;
&lt;p&gt;Best regards :)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/160050?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 15:56:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2552f14a-7fb2-482a-bfbd-8b9bcc043129</guid><dc:creator>Rabe</dc:creator><description>&lt;p&gt;It&amp;#39;s already fixed. Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/159999?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 14:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a22fd02-ac57-41dc-90fb-93a59210d487</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hard to know what you have done without seeing your code. Please post a new&amp;nbsp;question where you described your steps and post the code/project. That way we can help you debug the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/159874?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 08:05:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4ee2b4a-a8e0-47a0-a5dd-86ab98b0da70</guid><dc:creator>Rabe</dc:creator><description>&lt;p&gt;Excuse me Jorgen, I used that simple code from&amp;nbsp;&lt;a href="https://github.com/andenore/NordicSnippets/tree/master/examples/saadc"&gt;NordicSnippets GitHub page&lt;/a&gt; with saadc project as background to compile and when I start the program with Segger I always get 0 as result. Any idea? Would I have to change something from sdk_config.h? I would like to read the battery level of my DK PCA10040. Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77589?ContentTypeID=1</link><pubDate>Mon, 27 Feb 2017 09:49:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1bff9a0-8acc-4536-b87d-b30e6a15e753</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You are correct. The example is set to a resolution of 14 bits, and measures the VDD voltage of the board. You can change which pin is measured on &lt;a href="https://github.com/andenore/NordicSnippets/blob/master/examples/saadc/main.c#L22"&gt;line 22&lt;/a&gt;. The SAADC result is converted to voltage and stored in the variable &lt;code&gt;precise_result&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77588?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2017 19:05:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db34a2a6-3fbe-4599-8a7c-e1800768580e</guid><dc:creator>Remo</dc:creator><description>&lt;p&gt;...mmmh maybe i am completely wrong, but i try the code on the example without an result i get an result on the varaible &amp;quot;result&amp;quot; this result is about 12000 and changes +/- 10 on every round.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77586?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2017 19:04:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a179aea2-68c9-418c-a961-0b49ad23793e</guid><dc:creator>Remo</dc:creator><description>&lt;p&gt;what do the Task_sample? How i can find the nrf_dr_saadc ?
i had only copiing the code from an sample. But i the PIC MCU world was this ADC read simpler :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77590?ContentTypeID=1</link><pubDate>Fri, 24 Feb 2017 19:02:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b82113a4-63db-4751-aac6-fa9c663ae40f</guid><dc:creator>Remo</dc:creator><description>&lt;p&gt;...mmmh  maybe i am completely wrong, but i try the code on the example without an result
i get an result on the varaible &amp;quot;result&amp;quot; this result is about 12000 and changes +/- 10 on every round.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
  uint32_t err_code;
  bool erase_bonds;
	__WFE();
  // Initialize.
//APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
//uart_init();

//buttons_leds_init(&amp;amp;erase_bonds);
//ble_stack_init();
//    gap_params_init();
//    services_init();
//    advertising_init();
//    conn_params_init();

//    printf(&amp;quot;\r\nUART Start!\r\n&amp;quot;);
//    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
//    APP_ERROR_CHECK(err_code);



// Enter main loop.
for (;;)
{
			//#define EX1_COUNT 5
			//float ex1_result_f[EX1_COUNT];
			//int16_t ex1_result[EX1_COUNT];
    //power_manage();
			//read_right_hand_keys();

			volatile int16_t result = 0;
			volatile float precise_result = 0;

			// Start HFCLK from crystal oscillator, this will give the SAADC higher accuracy
			NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
			while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
			NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;

			// Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/6 gain.
			NRF_SAADC-&amp;gt;CH[0].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6    &amp;lt;&amp;lt; SAADC_CH_CONFIG_GAIN_Pos) |
																(SAADC_CH_CONFIG_MODE_SE         &amp;lt;&amp;lt; SAADC_CH_CONFIG_MODE_Pos) |
																(SAADC_CH_CONFIG_REFSEL_Internal &amp;lt;&amp;lt; SAADC_CH_CONFIG_REFSEL_Pos) |
																(SAADC_CH_CONFIG_RESN_Bypass     &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESN_Pos) |
																(SAADC_CH_CONFIG_RESP_Bypass     &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESP_Pos) |
																(SAADC_CH_CONFIG_TACQ_3us        &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos);

			// Configure the SAADC channel with VDD as positive input, no negative input(single ended).
			NRF_SAADC-&amp;gt;CH[0].PSELP = SAADC_CH_PSELP_PSELP_VDD &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
			NRF_SAADC-&amp;gt;CH[0].PSELN = SAADC_CH_PSELN_PSELN_NC &amp;lt;&amp;lt; SAADC_CH_PSELN_PSELN_Pos;

			// Configure the SAADC resolution.
			NRF_SAADC-&amp;gt;RESOLUTION = SAADC_RESOLUTION_VAL_14bit &amp;lt;&amp;lt; SAADC_RESOLUTION_VAL_Pos;

			// Configure result to be put in RAM at the location of &amp;quot;result&amp;quot; variable.
			NRF_SAADC-&amp;gt;RESULT.MAXCNT = 1;
			NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)&amp;amp;result;

			// No automatic sampling, will trigger with TASKS_SAMPLE.
			NRF_SAADC-&amp;gt;SAMPLERATE = SAADC_SAMPLERATE_MODE_Task &amp;lt;&amp;lt; SAADC_SAMPLERATE_MODE_Pos;

			// Enable SAADC (would capture analog pins if they were used in CH[0].PSELP)
			NRF_SAADC-&amp;gt;ENABLE = SAADC_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos;

			// Calibrate the SAADC (only needs to be done once in a while)
			NRF_SAADC-&amp;gt;TASKS_CALIBRATEOFFSET = 1;
			while (NRF_SAADC-&amp;gt;EVENTS_CALIBRATEDONE == 0);
			NRF_SAADC-&amp;gt;EVENTS_CALIBRATEDONE = 0;
			while (NRF_SAADC-&amp;gt;STATUS == (SAADC_STATUS_STATUS_Busy &amp;lt;&amp;lt;SAADC_STATUS_STATUS_Pos));

			// Start the SAADC and wait for the started event.
			NRF_SAADC-&amp;gt;TASKS_START = 1;
			while (NRF_SAADC-&amp;gt;EVENTS_STARTED == 0);
			NRF_SAADC-&amp;gt;EVENTS_STARTED = 0;

			// Do a SAADC sample, will put the result in the configured RAM buffer.
			NRF_SAADC-&amp;gt;TASKS_SAMPLE = 1;
			while (NRF_SAADC-&amp;gt;EVENTS_END == 0);
			NRF_SAADC-&amp;gt;EVENTS_END = 0;

			// Convert the result to voltage
			// Result = [V(p) - V(n)] * GAIN/REFERENCE * 2^(RESOLUTION)
			// Result = (VDD - 0) * ((1/6) / 0.6) * 2^14
			// VDD = Result / 4551.1
			precise_result = (float)result / 4551.1f;
			precise_result; // to get rid of set but not used warning

			// Stop the SAADC, since it&amp;#39;s not used anymore.
			NRF_SAADC-&amp;gt;TASKS_STOP = 1;
			while (NRF_SAADC-&amp;gt;EVENTS_STOPPED == 0);
			NRF_SAADC-&amp;gt;EVENTS_STOPPED = 0;
		
		

		

}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77587?ContentTypeID=1</link><pubDate>Thu, 23 Feb 2017 09:42:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6fadb8a-6d9f-4f5e-88d5-b2a211cd303d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can find an example of a simple read using the SAADC on the &lt;a href="https://github.com/andenore/NordicSnippets/tree/master/examples/saadc"&gt;NordicSnippets GitHub page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you want to use the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.2.0/hardware_driver_saadc.html?cp=4_0_1_2_13"&gt;SAADC driver&lt;/a&gt;, included in the SDK, you can find a simple example in &lt;a href="https://devzone.nordicsemi.com/question/105734/why-there-is-no-easy-api-for-analog-input-of-nrf52-saadc/?answer=106511#post-id-106511"&gt;this thead&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple analog read on nrf52</title><link>https://devzone.nordicsemi.com/thread/77585?ContentTypeID=1</link><pubDate>Thu, 23 Feb 2017 08:57:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfc59d32-6eb9-4dfb-964b-7b76a67c9a85</guid><dc:creator>andribiotico</dc:creator><description>&lt;p&gt;Correct me if I&amp;#39;m wrong, but I can&amp;#39;t see &amp;quot;where&amp;quot; do you trigger the TASK_SAMPLE. Why don&amp;#39;t you use the library &amp;quot;nrf_dr_saadc&amp;quot;? It&amp;#39;s very easy to use&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>