<?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>BLE + ADC + optimisation level</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9063/ble-adc-optimisation-level</link><description>Hello to everyone!
Please, tell me, why ADC may can&amp;#39;t be rightly initialised after BLE stack init? It&amp;#39;s happen only when I use Optimisation level 0 instead 3.
Thank you so much!</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Sep 2015 15:35:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9063/ble-adc-optimisation-level" /><item><title>RE: BLE + ADC + optimisation level</title><link>https://devzone.nordicsemi.com/thread/33373?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2015 15:35:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1e7ed7b-2fba-4d11-9213-88cd1c2a0ce6</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thank you for your question&lt;/p&gt;
&lt;p&gt;I see that you initialize a pin as output in your initialization routine, but you do it again in your second code block. You should only initialize the pin once. You should also enable the ADC only once.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + optimisation level</title><link>https://devzone.nordicsemi.com/thread/33372?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2015 14:32:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a285d80a-72c0-4ad3-ba31-bd19346607e3</guid><dc:creator>jane_raid</dc:creator><description>&lt;p&gt;This is an initialisation of ADC:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    nrf_gpio_cfg_output(PIN_BATTERY_CHARGE_ON);
nrf_gpio_pin_set(PIN_BATTERY_CHARGE_ON);

/* Enable interrupt on ADC sample ready event*/		
NRF_ADC-&amp;gt;INTENSET = ADC_INTENSET_END_Msk;   
sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);  
sd_nvic_EnableIRQ(ADC_IRQn);

NRF_ADC-&amp;gt;CONFIG	= (ADC_CONFIG_EXTREFSEL_None &amp;lt;&amp;lt; ADC_CONFIG_EXTREFSEL_Pos) | (ADC_CONFIG_PSEL_AnalogInput6 &amp;lt;&amp;lt; ADC_CONFIG_PSEL_Pos)	| (ADC_CONFIG_REFSEL_VBG &amp;lt;&amp;lt; ADC_CONFIG_REFSEL_Pos)		| (ADC_CONFIG_INPSEL_AnalogInputTwoThirdsPrescaling &amp;lt;&amp;lt; ADC_CONFIG_INPSEL_Pos) | (ADC_CONFIG_RES_8bit &amp;lt;&amp;lt; ADC_CONFIG_RES_Pos);			

/* Enable ADC*/
NRF_ADC-&amp;gt;ENABLE = ADC_ENABLE_ENABLE_Enabled;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and this is a place when I&amp;#39;m try to get a data from ADC&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t p_is_running = 0;

sd_clock_hfclk_request();
while(! p_is_running) {  							//wait for the hfclk to be available
	sd_clock_hfclk_is_running((&amp;amp;p_is_running));
}               

nrf_gpio_cfg_output(PIN_BATTERY_CHARGE_ON);
nrf_gpio_pin_set(PIN_BATTERY_CHARGE_ON);

NRF_ADC-&amp;gt;ENABLE = ADC_ENABLE_ENABLE_Enabled;
NRF_ADC-&amp;gt;TASKS_START = 1;							//Start ADC sampling



while (NRF_ADC-&amp;gt;EVENTS_END == 0);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;It&amp;#39;s run on while (NRF_ADC-&amp;gt;EVENTS_END == 0); again and again and in some runs go to HardFaultHandler&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE + ADC + optimisation level</title><link>https://devzone.nordicsemi.com/thread/33371?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2015 13:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6090976-5cb8-492e-8b8b-65bda367bc22</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;Are you using ADC driver from SDK? Please provide us some code that causes the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>