<?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>Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11392/porting-ble_app_uart-into-twi_master_with_slave</link><description>Hi, 
 I am using the nRF52 with code from SDK 9.2, as well as the S132 softdevice. I basically ported code from the ble_uart_app into the twi_example to send data over bluetooth. 
 I tried to port the ble_uart functions from the main file, as well as</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Jan 2016 08:14:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11392/porting-ble_app_uart-into-twi_master_with_slave" /><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42939?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2016 08:14:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef81e989-df23-4d39-886d-04ef282f428b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thank you for updating this thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42938?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2016 01:13:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d0c8121-2079-48bc-bc0a-0a0ea952162f</guid><dc:creator>JudePinto</dc:creator><description>&lt;p&gt;To anyone curious about a solution: &lt;a href="https://devzone.nordicsemi.com/question/31703/nrf51822-iram-and-irom-settings-for-s110-sd/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That thread decribes the start position and size of RAM/ROM in the Options for Target ------&amp;gt; Target.&lt;/p&gt;
&lt;p&gt;I ported code into the ble_app_uart that was originally a peripheral example, in order to utilize I2C/TWI functionality. For the peripheral examples, the RAM starts at 0x0, which is not compatible with the ble_app_uart, because the softdevice needs to be flashed first and takes up space from 0x0.&lt;/p&gt;
&lt;p&gt;RAM settings for the application need to be changed so the device flashes starting at a larger value to leave space for the softdevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42937?ContentTypeID=1</link><pubDate>Wed, 20 Jan 2016 01:08:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc694683-6812-47d5-87c5-8dcba40abbbe</guid><dc:creator>JudePinto</dc:creator><description>&lt;p&gt;Please see my answer below&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42936?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 22:06:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8748194c-21d0-4976-aa1d-7aae0fbde236</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It would be perfect if you can update this thread once you get an answer from the portal..Good Luck&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42935?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 21:53:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4da0f88-5862-453b-a49c-66d13c1b7edb</guid><dc:creator>JudePinto</dc:creator><description>&lt;p&gt;Aryan, I still need help with this request, so I submitted it through the support portal. I did not want to duplicate the work for the nordic support staff, so I deleted this thread. Is that okay?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42934?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 21:31:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6231bce3-3015-4ba4-9d3f-231dd6162aa0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Judepinto24,
Please do not delete the thread with many comments. It will be useful for others to see your discussion.
Did you mean to mark it as completed?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42933?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 03:55:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:657eae0a-0d95-40f6-a37e-23982ff0e831</guid><dc:creator>JudePinto</dc:creator><description>&lt;p&gt;Okay, I took what you said and used a debugger. The code stops working at ble_stack_init(). It does not get to err_code. Also, sorry, here is the full code.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
	uart_config(); 

	printf(&amp;quot;\nTWI Sensor Example\r\n&amp;quot;);
	//BT
	uint32_t err_code;
	bool erase_bonds;
	uint8_t buffer[BLE_NUS_MAX_DATA_LEN] = {0};
	twi_init(); //not BT
	printf(&amp;quot;TWI&amp;quot;);
	MC3610 MC; //not BT
	MC.start(); //not BT

	// Initialize.
	APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
	buttons_leds_init(&amp;amp;erase_bonds);
	ble_stack_init();
	gap_params_init();
	services_init();
	advertising_init();
	conn_params_init();
	err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
	APP_ERROR_CHECK(err_code);
	//BT end

	#ifdef TEST_MODE //TEST_MODE must be defined in the options for IDE
	jazz_unit_test_mcube();
	#endif

	while(1) {
		mc3610_acc_t rawData = MC.readRawAccel();
		printf(&amp;quot;%*.4f,%*.4f,%*.4f\r\n&amp;quot;,6,rawData.XAxis_g,6,rawData.YAxis_g,6,rawData.ZAxis_g); 
		sprintf((char*)buffer,&amp;quot;%.4f,%.4f,%.4f\r\n&amp;quot;, rawData.XAxis_g, rawData.YAxis_g, rawData.ZAxis_g);
		
		if(m_conn_handle != BLE_CONN_HANDLE_INVALID)
		{
			err_code = ble_nus_string_send(&amp;amp;m_nus, buffer, sizeof(buffer));
			if (err_code != NRF_ERROR_INVALID_STATE)
			{
				APP_ERROR_CHECK(err_code);
			}
		}

		power_manage(); //puts it in sleep mode. can be woken with interrupt

		nrf_delay_ms(10);

	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42932?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 02:07:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06cd52c9-fdf9-4800-9bf4-6453f92d9ce8</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;well you should have something to stop main() just exiting. Currently you start advertising and if that&amp;#39;s your real code, as soon as that&amp;#39;s done, you&amp;#39;re off the end of main and depending on what you&amp;#39;re building with you could run into a loop, which would work, or a load of shutdown code, which wouldn&amp;#39;t.&lt;/p&gt;
&lt;p&gt;If you have an infinite loop elsewhere then either&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You&amp;#39;re in it already - ie does twi_init() start the infinite loop, in which case you&amp;#39;re never going to get to the rest of the code or&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Your infinite loop is triggered later by a timer or connection and you&amp;#39;ve already left main() before you get there.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;just putting while(1) __wfe() at the end of main is a good idea.&lt;/p&gt;
&lt;p&gt;If you have a debugger, use it. If you don&amp;#39;t, then you&amp;#39;re just going to have to start commenting things out piece by piece until you find out where you are. I never know why people debug with UART, too hard.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42931?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 01:57:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8004413-e03f-4a61-8d52-6d199f002d0c</guid><dc:creator>JudePinto</dc:creator><description>&lt;p&gt;hello,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I do have a infinite while loop where I am taking data. I removed power manage, because I am not using interrupts to wake the device up every time I get a sample from the sensor. Is power manage absolutely necessary?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;2/3. I have been debugging through UART. Since UART messages are not working, I cannot see the err_code value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Porting ble_app_uart into twi_master_with_slave</title><link>https://devzone.nordicsemi.com/thread/42930?ContentTypeID=1</link><pubDate>Tue, 19 Jan 2016 01:01:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05600e80-8bcb-4ac5-8190-7d43f8bf4806</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;well for a start - there&amp;#39;s no infinite loop at the end of that main() routine. Usually you&amp;#39;d have&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while( 1 )
    power_manage() 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or _wfe() or similar&lt;/p&gt;
&lt;p&gt;Secondly - are you even getting to ble_advertising_start(), use the debugger.&lt;/p&gt;
&lt;p&gt;Thirdly- what is &lt;code&gt;err_code&lt;/code&gt; at the end, is it zero or are you just going to the error handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>