<?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>Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15805/problem-when-switching-role-from-peripheral-to-central-on-s120</link><description>Hi, 
 I am now on implementing a dynamic change between the 2 possible roles central and peripheral.
I try to do this like described here:
 nordicsemi.com/question/35367... 
But when trying to switch from peripheral to central, I always get an error</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Oct 2016 06:43:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15805/problem-when-switching-role-from-peripheral-to-central-on-s120" /><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60333?ContentTypeID=1</link><pubDate>Wed, 05 Oct 2016 06:43:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bcd8d6f-10ec-46cf-a954-8f8dca2f76b1</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi RK, thanks for that additional information. Of course you are right. Unfortunately this error codes (with base 0x1000) where not in my scope. So I didn`t know them at that point of time... :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60334?ContentTypeID=1</link><pubDate>Wed, 05 Oct 2016 06:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8380dab-3e01-49db-89dd-282004037f25</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;The error code told you that by the way. 4097 is 0x1001&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define 	NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION   (NRF_ERROR_SDM_BASE_NUM + 1)

#define 	NRF_ERROR_SDM_BASE_NUM   (0x1000)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;regrettably not all error codes in the SDK/softdevice are unique, but I think that one is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60332?ContentTypeID=1</link><pubDate>Wed, 05 Oct 2016 06:24:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56834ecc-3a5c-40f5-8850-865a4b456c32</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Finally got it. There was an error when initialising some timers on another point of the project. For these timers, the wrong interrupt priority was used. This priority was reserved for the softdevice. Changed the interrupt priority and the role switching worked.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60329?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 08:40:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c62605f-a867-4ae8-b8af-cc9b3877766a</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I don&amp;#39;t think so, but I haven&amp;#39;t done much testing with switching roles with the S120.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60331?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 14:23:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74c1e6f4-8f06-46c5-a3bc-84308f702fc7</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Ok, I did a quick test with the more simple ble_app_uart_c example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ble_stack_init(BLE_GAP_ROLE_PERIPH); sd_softdevice_disable(); ble_stack_init(BLE_GAP_ROLE_CENTRAL);&lt;/code&gt;
This worked. So there must be a problem with the rest of my application code. I am using SPI, TWI and UART in my final application. Do I have to take care with one of these drivers when disabling the ble stack / switching the role?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60330?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 12:48:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5612a36f-f4af-4dd7-a706-240abfd15269</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I tried your code with SDK 8.1.0, with compatible S120 SoftDevice. Seems to be working fine as well. Could you upload a project which reproduces the issue? Have you changed any of the libraries? I just tried this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = ble_stack_init(BLE_GAP_ROLE_PERIPH);
APP_ERROR_CHECK(err_code);

err_code = sd_softdevice_disable();
APP_ERROR_CHECK(err_code);

err_code = ble_stack_init(BLE_GAP_ROLE_CENTRAL);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60328?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 12:00:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:560f683b-0e33-4c2d-ba87-1180b4fcdb6a</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hello, thanks for testing my code. I am working with the SDK 8.1.0 and the integrated sofdevice version. Do I have to switch the SDK version!? I think this would be a bigger job for me to do because it is an existing project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60327?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 11:38:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c1979ae-8150-47cc-9900-0babd1eacb11</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Ok. I tried your code. Seems to be working fine here. I tested with S120 v2.1.0 and SDK 10.0.0. Are these the versions you are working with as well? I think you should use softdevice_handler_sd_disable() instead of sd_softdevice_disable() directly, but I don&amp;#39;t think that is the cause of your issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60326?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 10:09:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80ee5356-8607-47fd-9813-253a7193f286</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Is it possible, that the error code can not be resolved properly because it is part of a macro? (&lt;code&gt;SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);&lt;/code&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60325?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 09:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82145520-a27e-4f35-8a5f-4bd4a0133f67</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hello Petter, I have turned off all optimizations. The error is thrown from &lt;code&gt;sd_softdevice_enable(clock_source, softdevice_assertion_handler);&lt;/code&gt;. It happens in &lt;code&gt;softdevice_handler_init()&lt;/code&gt; (softdevice_handler.c).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60324?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 09:11:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46076ccb-2260-4c1f-93a8-ff68589a2bd6</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Have you turned off optimization? Could you try to debug and see from where in softdevice_handler_init() this error is set?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60323?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 13:57:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90e64767-c03d-4283-839a-4a8f7f451c16</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Ok, by stepping through the code with the debugger, I can see that the error is thrown from the &lt;code&gt;sd_softdevice_enable(clock_source, softdevice_assertion_handler);&lt;/code&gt; function in softdevice_handler.c. I think, because &lt;code&gt;SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);&lt;/code&gt; is a macro, the debugger can not resolve that properly. Nevertheless, for me 4097 is not a valid error code. Are there any other preconditions that have to be setted properly to switch the role?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem when switching role from peripheral to central on S120</title><link>https://devzone.nordicsemi.com/thread/60322?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2016 11:59:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc529bfe-b6df-4204-9004-027c5cdc909e</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;It is not valid. It is returned by softdevice_handler_init()? Have you turned off optimization? Could you try to debug and see from where in softdevice_handler_init() this error is set?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>