<?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>How to configure &amp;quot;ble_nus_send_string&amp;quot; in nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6827/how-to-configure-ble_nus_send_string-in-nrf51822</link><description>Hi every body, 
 i try to use 10 bit ADC resolution instead of 8 bit in the ble_uard_adc example, the problem is the ble_nus_send_string is configure to 8 bit, how can i re-configure it to 16 bit to send a 10-bit ADC analog reading? 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 May 2015 14:43:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6827/how-to-configure-ble_nus_send_string-in-nrf51822" /><item><title>RE: How to configure "ble_nus_send_string" in nRF51822</title><link>https://devzone.nordicsemi.com/thread/24047?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 14:43:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c8deb8f-6da0-4058-aab6-aa15668b0ee6</guid><dc:creator>ahmed</dc:creator><description>&lt;p&gt;Thank alot my friend&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure "ble_nus_send_string" in nRF51822</title><link>https://devzone.nordicsemi.com/thread/24050?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 14:59:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6af0aa2f-b94d-4919-a5e3-a48f70a8de54</guid><dc:creator>ahmed</dc:creator><description>&lt;p&gt;Hi Stefan,&lt;/p&gt;
&lt;p&gt;The voltage on pin2 around 1.5 to 1.8 volt, i try to use potentiometer on the input but the value of adc_result[1] still 0.&lt;/p&gt;
&lt;p&gt;The row data that can be sent over the air is it just numerical data or alphabetical data? because i need to separate between the two adc result, and the receiver side you mean ( PC application or BLE module), now the pc application that i programmed receive the adc result like this type &amp;quot;result 1,result 2&amp;quot; but via wire and i want to make it via Bluetooth.&lt;/p&gt;
&lt;p&gt;Thank alot for your support&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure "ble_nus_send_string" in nRF51822</title><link>https://devzone.nordicsemi.com/thread/24049?ContentTypeID=1</link><pubDate>Wed, 06 May 2015 12:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6ef2754-d6f7-4351-b0a7-3d2fa3af93b2</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi ahmed&lt;/p&gt;
&lt;p&gt;What voltage are you feeding to Analog input pin 2 (AIN2 or P0.01)? I suspect that you have low voltage on AIN2, then you will get low ADC output value and the last two bits will be zero, which are the two bits put into adc_result[1]&lt;/p&gt;
&lt;p&gt;You can only send raw bytes over the air via the softdevice. If you want a specific format you need to apply that on the receiver side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure "ble_nus_send_string" in nRF51822</title><link>https://devzone.nordicsemi.com/thread/24048?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 15:43:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8914ad0c-1541-4729-870e-0f1b7a8129a8</guid><dc:creator>ahmed</dc:creator><description>&lt;p&gt;Dear Stefan,&lt;/p&gt;
&lt;p&gt;First of all , thank you very much four your support&lt;/p&gt;
&lt;p&gt;When i try to transmit two byte that mentioned above, i get a zero value in adc_result[1] and the adc_result[0] contains a normal value.&lt;/p&gt;
&lt;p&gt;Please i have another question, if i want to use two 10-bit ADC channels and send there values at same string but separated by comma &amp;quot;,&amp;quot; how can i do this?&lt;/p&gt;
&lt;p&gt;Thanks again for your valued advice&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to configure "ble_nus_send_string" in nRF51822</title><link>https://devzone.nordicsemi.com/thread/24046?ContentTypeID=1</link><pubDate>Mon, 04 May 2015 11:57:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e3f0ab2-9eab-4df2-8185-a439fb9bdae8</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi ahmed&lt;/p&gt;
&lt;p&gt;The input parameters in the ble_nus_send_string function include a length parameter and accept a pointer to data.&lt;/p&gt;
&lt;p&gt;To get 10-bit sampling, change the configuration to 10-bit&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//ADC initialization
static void adc_init(void)
{	
	/* 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) /* Bits 17..16 : ADC external reference pin selection. */
									| (ADC_CONFIG_PSEL_AnalogInput2 &amp;lt;&amp;lt; ADC_CONFIG_PSEL_Pos)					/*!&amp;lt; Use analog input 2 as analog input. */
									| (ADC_CONFIG_REFSEL_VBG &amp;lt;&amp;lt; ADC_CONFIG_REFSEL_Pos)							/*!&amp;lt; Use internal 1.2V bandgap voltage as reference for conversion. */
									| (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling &amp;lt;&amp;lt; ADC_CONFIG_INPSEL_Pos) /*!&amp;lt; Analog input specified by PSEL with no prescaling used as input for the conversion. */
									| (ADC_CONFIG_RES_10bit &amp;lt;&amp;lt; ADC_CONFIG_RES_Pos);									/*!&amp;lt; 8bit ADC resolution. */ 
	
	/* Enable ADC*/
	NRF_ADC-&amp;gt;ENABLE = ADC_ENABLE_ENABLE_Enabled;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So in order to transmit two bytes instead of one, you can do that as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Interrupt handler for ADC data ready event */
void ADC_IRQHandler(void)
{
	uint8_t adc_result[2];
	
	/* Clear dataready event */
	NRF_ADC-&amp;gt;EVENTS_END = 0;	

	/* Write ADC result both to the UART and over BLE */
	adc_result[0] = NRF_ADC-&amp;gt;RESULT;
	adc_result[1] = NRF_ADC-&amp;gt;RESULT &amp;gt;&amp;gt; 8;
	app_uart_put(adc_result[0]);
	app_uart_put(adc_result[1]);
	ble_nus_send_string(&amp;amp;m_nus, adc_result, 2);
	nrf_gpio_pin_toggle(LED_3);        //indicate on LED that the ADC interrupt handler is executing
	
	//Use the STOP task to save current. Workaround for PAN_028 rev1.5 anomaly 1.
	NRF_ADC-&amp;gt;TASKS_STOP = 1;
	
	//Release the external crystal
	sd_clock_hfclk_release();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Update 7.5.2015&lt;/strong&gt;
I include the code I have tested this with&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_example_5F00_with_5F00_softdevice_5F00_and_5F00_UART_5F00_send_5F00_two_5F00_bytes.zip"&gt;adc_example_with_softdevice_and_UART_send_two_bytes.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The procedure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Flash softdevice S110 7.1.0&lt;/li&gt;
&lt;li&gt;Insert  the above application into SDK 6.1.0,    compile and flash&lt;/li&gt;
&lt;li&gt;I used nRF51 DK but    other dev kits can be used as well,    i.e. nRF51 Dongle, nRF51422/nRF51822    development kit or nRF51422/nRF51822    evaluation kit&lt;/li&gt;
&lt;li&gt;Connect with Master    Control Panel, i.e. select the device    (name:Nordic_UART), discover    services, then enable services. You    should see non zero values being    notified. The image above shows the    received value in Master Control    Panel when the voltage is 2.0V on pin    P0.01&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Capture-_2D00_-ADC-10-bit-value-in-MCP.JPG" alt="image description" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>