<?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>Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37581/dynamic-reconfiguration-of-peripheral-hw-from-twi-to-spi</link><description>Our nRF52840 is communicating with a peripheral chip (let&amp;#39;s call it FOO) through an SPI interface. The FOO chip can be configured to use either TWI or SPI on the same pins (well TWI uses a subset of the SPI pins), the default mode after FOO reset is TWI</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Oct 2024 12:48:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37581/dynamic-reconfiguration-of-peripheral-hw-from-twi-to-spi" /><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/508150?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2024 12:48:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b704e325-5f72-47d7-8e6d-cc51ddff5469</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Dear&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/haakonsh"&gt;haakonsh&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am a bit confused to inform you that this discussion was just making a lot of noise for nothing. A few weeks ago I realized that the root cause of the problem was that the peripheral setup time (from the reset signal raising to the first access on the bus) was too short.&lt;br /&gt;For some reason this had gone unnoticed up to lately and I had sought the problem in the wrong direction and fixed it without understanding why the fix was making things work.&lt;br /&gt;At least I hope the discussion can be useful to other people in the sense that one should double check one more time that startup timings specs and other basic settings are fulfilled before blaming the SDK.&lt;br /&gt;&lt;br /&gt;Lots of thanks for your kind help anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149861?ContentTypeID=1</link><pubDate>Fri, 21 Sep 2018 14:01:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:471de303-a8f3-4280-8034-c258fb89f574</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Thank you for sharing your findings, we&amp;#39;ll try to reproduce it on our end and see what we find :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149587?ContentTypeID=1</link><pubDate>Thu, 20 Sep 2018 09:10:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82a5cbed-ecb4-48ba-9e4e-19da0b033cbe</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;For completeness, here is the patch that makes it work for me (I replaced the copy to array by some delay which I empirically found):&lt;/p&gt;
&lt;p&gt;diff --git a/nrf-sdk/modules/nrfx/drivers/src/nrfx_twi.c b/nrf-sdk/modules/nrfx/drivers/src/nrfx_twi.c&lt;br /&gt;index c7492bd4..c9080024 100644&lt;br /&gt;--- a/nrf-sdk/modules/nrfx/drivers/src/nrfx_twi.c&lt;br /&gt;+++ b/nrf-sdk/modules/nrfx/drivers/src/nrfx_twi.c&lt;br /&gt;@@ -49,6 +49,8 @@&lt;br /&gt; #include &amp;lt;nrfx_twi.h&amp;gt;&lt;br /&gt; #include &amp;lt;hal/nrf_gpio.h&amp;gt;&lt;br /&gt; #include &amp;quot;prs/nrfx_prs.h&amp;quot;&lt;br /&gt;+#include &amp;quot;nrf_delay.h&amp;quot;&lt;br /&gt;+&lt;br /&gt; &lt;br /&gt; #define NRFX_LOG_MODULE TWI&lt;br /&gt; #include &amp;lt;nrfx_log.h&amp;gt;&lt;br /&gt;@@ -395,6 +397,10 @@ static nrfx_err_t twi_tx_start_transfer(twi_control_block_t * p_cb,&lt;br /&gt; &lt;br /&gt; // In case TWI is suspended resume its operation.&lt;br /&gt; nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_RESUME);&lt;br /&gt;+&lt;br /&gt;+ if(p_twi == (NRF_TWI_Type*)0x40003000)&lt;br /&gt;+ nrf_delay_us(300);&lt;br /&gt;+ &lt;br /&gt; nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTTX);&lt;br /&gt; &lt;br /&gt; (void)twi_send_byte(p_twi, p_data, length, &amp;amp;p_cb-&amp;gt;bytes_transferred, no_stop);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please note that the&amp;nbsp;&amp;laquo; if(p_twi == (NRF_TWI_Type*)0x40003000) &amp;raquo; is there just because I want to affect TWI0 only, which is the one concerned by my specific design, and minimize any side effect on the rest of the system. This patch is definitely not a fix, just some hack.&lt;/p&gt;
&lt;p&gt;Hopefully, you can help with this.&lt;/p&gt;
&lt;p&gt;BTW, as I wrote, I am currently still using sdk15,0,0, maybe this issue is already fixed in 15,0,2.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149437?ContentTypeID=1</link><pubDate>Wed, 19 Sep 2018 12:20:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8075b132-b2d3-4a56-85a5-fb388e2860a4</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have done some experiments, and I realized a few things.&lt;/p&gt;
&lt;p&gt;First, as you remember I had a version of the FW, let us call it V0, in which I had no callback neither in running the program freely with just RTT logging, nor in debugging session, and a second version, let us call it V1, in which I had the callback when running in debugger but not when running the SW freely with just RTT logging.&lt;/p&gt;
&lt;p&gt;So the first thing which I have understood is that in V0 there was a mistake of mine by which the NRFX_PRS_BOX_0_ENABLED, and NRFX_TWI0_ENABLED and TWI0_ENABLED flags were not dispatched to all the FW but only to the part which was calling and configuring the TWI0. This mistake may explain the problem, but not fully because when I placed some &amp;laquo;&amp;nbsp;#error Voil&amp;agrave;&amp;nbsp;&amp;raquo; in the nrfx_twi.c code under condition of these flags I could observe that nrfx_twi.c had the flags.&lt;/p&gt;
&lt;p&gt;Anyway, the problem still exists with V1, and that seems to be some real time issue in the way the TWI0 is configured. Probably there should be some &amp;laquo;&amp;nbsp;nrf_delay_us(&amp;hellip;)&amp;nbsp;&amp;raquo; just before the &amp;laquo;&amp;nbsp;nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTTX)&amp;nbsp;&amp;raquo; possibly depending on the TWI configured speed.&lt;/p&gt;
&lt;p&gt;As I could not see the registers under the debugger, because I cannot reproduce the bug this way, what I did is place some &amp;laquo;&amp;nbsp;memcpy(temp_twi_register_state,p_twi,sizeof(NRF_TWI_Type));&amp;nbsp;&amp;raquo; just before the &lt;span&gt;&amp;laquo;&amp;nbsp;nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTTX)&amp;nbsp;&amp;raquo;&lt;/span&gt;. Doing this created some delay before &lt;span&gt;&amp;laquo;&amp;nbsp;nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STARTTX)&amp;nbsp;&amp;raquo;&lt;/span&gt;&amp;nbsp;and that sufficed to make it work (ie that caused the call back to be called).&lt;/p&gt;
&lt;p&gt;For your information, here is the register state dump:&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: twi register state = [1420]:&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0100000000000000000000000100000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000001000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0100000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 05000000000000001b00000008000000ffffffffffffffff0000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000006806000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000200000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 0000000000000000000000000000000000000000000000000000000000000000&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; FOO: 010000000000000069000000&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149256?ContentTypeID=1</link><pubDate>Tue, 18 Sep 2018 13:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45580301-7bee-47a4-b3b6-c258dbad9c27</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;We need the content of the registers before the &lt;span&gt;TASKS_STARTTX is triggered, but after the driver has set up the transfer.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149094?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 15:45:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34dcae4d-382c-4691-a4e7-d068fa6b3902</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;OK, I was a bit too quick in writing that it had worked. In fact there is exactly the same problem in the same conditions.&lt;/p&gt;
&lt;p&gt;When I run the program with this sort of command line:&lt;/p&gt;
&lt;p&gt;nrfjprog --reset &amp;amp;&amp;amp; JLinkRTTLogger -Device nrf52840_XXAA -If SWD -Speed 4000 -RTTCHannel 0 /dev/stdout&lt;/p&gt;
&lt;p&gt;then I get the problem occurring (ie my FreeRTOS queue is timed out, which calls the app error handler).&lt;/p&gt;
&lt;p&gt;We are using SEGGER backend for the NRF LOGGER, and it seems that this is what creates the condition that makes the problem happen.&lt;/p&gt;
&lt;p&gt;When I run the same program under the debugger (which is what I did to post the content of registers as you required), then I can get through the line at which the problem occurs without it occurring --- that is why I thought in my previous post that the problem had disappeared.&lt;/p&gt;
&lt;p&gt;In fact it is still there but I was not in the conditions in which it happens.&lt;/p&gt;
&lt;p&gt;Maybe I should push the TWI registers content to the logger so that we can see what is their content in the conditions when the problem happens.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149089?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 14:59:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31385b8b-9acd-4a0d-9f9d-3f2a5696fdaa</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Ooops&amp;hellip; SOMETHING&amp;nbsp;has happened, it has worked !&lt;/p&gt;
&lt;p&gt;I must admit that it is not exactly the same FW as that on which I observed the issue when I opened the thread, I will try to make a git clone of the same version to see if I can reproduce the problem again&amp;hellip;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149085?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 14:52:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02b281e3-7f09-45e4-b611-28d0584d8be2</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;To be more complete, I also printed the transfer descriptor, it is as follows (I just obfuscated the device address):&lt;/p&gt;
&lt;p&gt;(gdb) print /x *p_xfer_desc&lt;br /&gt;print /x *p_xfer_desc&lt;br /&gt;$6 = {type = 0x2, address = 0x&amp;hellip;, primary_length = 0x1, secondary_length = 0x1, p_primary_buf = 0x200041e3, &lt;br /&gt; p_secondary_buf = 0x200041e0}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/149084?ContentTypeID=1</link><pubDate>Mon, 17 Sep 2018 14:45:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b28d8903-341f-44d2-bfc2-d4bda84768f2</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thank you vey much for the feedback, I will try to answer point by point.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/37581/dynamic-reconfiguration-of-peripheral-hw-from-twi-to-spi/148759"]Do you see any strange behavior on the TWI lines?[/quote]
&lt;p&gt;Well, I cannot say this now, I need to make some setup so that I can observes the line on the scope, I am afraid I don&amp;#39;t have easy&amp;nbsp;easy test point to get them right away.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/37581/dynamic-reconfiguration-of-peripheral-hw-from-twi-to-spi/148759"]What is the state of the TWI0 registers before the STARTRX or TX&amp;nbsp; is triggered?[/quote]
&lt;p&gt;The first function that is called is&amp;nbsp;nrfx_twi_xfer, when I am at line 601 of file&amp;nbsp;nrfx_twi.c here is what I can print in gdb:&lt;/p&gt;
&lt;p&gt;nrfx_twi_xfer (p_instance=0x1d210 &amp;lt;m_FOO_twi_transient_i2c&amp;gt;, p_xfer_desc=0x200041cc, flags=0)&lt;br /&gt; at /Users/vincentbelaiche/Projects/biosency-fw_dev3.4/boraconnect-firmware/nrf-sdk/modules/nrfx/drivers/src/nrfx_twi.c:583&lt;br /&gt;583 nrfx_err_t err_code = NRFX_SUCCESS;&lt;br /&gt;(gdb) until&lt;br /&gt;until&lt;br /&gt;584 twi_control_block_t * p_cb = &amp;amp;m_cb[p_instance-&amp;gt;drv_inst_idx];&lt;br /&gt;(gdb) until&lt;br /&gt;until&lt;br /&gt;601 err_code = twi_xfer(p_cb, (NRF_TWI_Type *)p_instance-&amp;gt;p_twi, p_xfer_desc, flags);&lt;br /&gt;(gdb) print *p_cb&lt;br /&gt;print *p_cb&lt;br /&gt;$1 = {handler = 0x7461 &amp;lt;FOO_transient_twi_cb&amp;gt;, p_context = 0x20002790 &amp;lt;m_FOO_context_s&amp;gt;, int_mask = 0, xfer_desc = {&lt;br /&gt; type = NRFX_TWI_XFER_TX, address = 0 &amp;#39;\000&amp;#39;, primary_length = 0, secondary_length = 0, p_primary_buf = 0x0 &amp;lt;__isr_vector&amp;gt;, &lt;br /&gt; p_secondary_buf = 0x0 &amp;lt;__isr_vector&amp;gt;}, flags = 0, p_curr_buf = 0x0 &amp;lt;__isr_vector&amp;gt;, curr_length = 0 &amp;#39;\000&amp;#39;, &lt;br /&gt; curr_no_stop = false, state = NRFX_DRV_STATE_POWERED_ON, error = false, busy = false, repeated = false, &lt;br /&gt; bytes_transferred = 0 &amp;#39;\000&amp;#39;, hold_bus_uninit = true}&lt;br /&gt;(gdb) print /x *((NRF_TWI_Type *)p_instance-&amp;gt;p_twi)&lt;br /&gt;print /x *((NRF_TWI_Type *)p_instance-&amp;gt;p_twi)&lt;br /&gt;$3 = {TASKS_STARTRX = 0x0, RESERVED0 = 0x0, TASKS_STARTTX = 0x0, RESERVED1 = {0x0, 0x0}, TASKS_STOP = 0x0, RESERVED2 = 0x0, &lt;br /&gt; TASKS_SUSPEND = 0x0, TASKS_RESUME = 0x0, RESERVED3 = {0x0 &amp;lt;repeats 56 times&amp;gt;}, EVENTS_STOPPED = 0x0, EVENTS_RXDREADY = 0x0, &lt;br /&gt; RESERVED4 = {0x0, 0x0, 0x0, 0x0}, EVENTS_TXDSENT = 0x0, RESERVED5 = 0x0, EVENTS_ERROR = 0x0, RESERVED6 = {0x0, 0x0, 0x0, 0x0}, &lt;br /&gt; EVENTS_BB = 0x0, RESERVED7 = {0x0, 0x0, 0x0}, EVENTS_SUSPENDED = 0x0, RESERVED8 = {0x0 &amp;lt;repeats 45 times&amp;gt;}, SHORTS = 0x0, &lt;br /&gt; RESERVED9 = {0x0 &amp;lt;repeats 64 times&amp;gt;}, INTENSET = 0x0, INTENCLR = 0x0, RESERVED10 = {0x0 &amp;lt;repeats 61 times&amp;gt;, 0x1, &lt;br /&gt; 0x0 &amp;lt;repeats 48 times&amp;gt;}, ERRORSRC = 0x0, RESERVED11 = {0x0 &amp;lt;repeats 14 times&amp;gt;}, ENABLE = 0x5, RESERVED12 = 0x0, PSEL = {&lt;br /&gt; SCL = 0x1b, SDA = 0x8}, RESERVED13 = {0xffffffff, 0xffffffff}, RXD = 0x0, TXD = 0x0, RESERVED14 = 0x0, FREQUENCY = 0x6680000, &lt;br /&gt; RESERVED15 = {0x0 &amp;lt;repeats 12 times&amp;gt;, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0}, ADDRESS = 0x0}&lt;br /&gt;(gdb)&lt;/p&gt;
&lt;p&gt;Please note that in the above I have renamed some of my symbols with &amp;hellip;_FOO_&amp;hellip; to be consistent with the beginning of this discussion.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/37581/dynamic-reconfiguration-of-peripheral-hw-from-twi-to-spi/148759"]Have you tried using the TWIM/TWIS drivers? As they use EasyDMA and PPI shortcuts they require less CPU resources, whom I assume you are in dire need of if your running an RTOS on top of the SoftDevice.&amp;nbsp;[/quote]
&lt;p&gt;No, I have not tried that yet, though it is a good idea certainly.&lt;/p&gt;
&lt;p&gt;The FW which I am using is not the full application FW, it is a test FW with only the modules at stake. There is no SoftDevice in it, but the RTOS is there.&lt;/p&gt;
&lt;p&gt;I must admit that the NRF_LOGGER is used and may take some resource, however I don&amp;#39;t think that it is the root cause because for some other module with TWI interfacing in a similar way and quite intensive logging there is no problem.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/148759?ContentTypeID=1</link><pubDate>Fri, 14 Sep 2018 09:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e97a69c6-04d1-4992-8d7b-c15e94f11500</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;The only two reasons I can think of is that the interrupts are disabled&amp;nbsp;or the CPU is stuck in a higher priority ISR. The TWI peripheral should fire the ERROR event if any operation outside the spec is occuring.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Do you see any strange behavior on the TWI lines?&lt;br /&gt;&lt;br /&gt;What is the state of the TWI0 registers before the STARTRX or TX&amp;nbsp; is triggered?&lt;br /&gt;&lt;br /&gt;Have you tried using the TWIM/TWIS drivers? As they use EasyDMA and PPI shortcuts they require less CPU resources, whom I assume you are in dire need of if your running an RTOS on top of the SoftDevice.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/148751?ContentTypeID=1</link><pubDate>Fri, 14 Sep 2018 09:05:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd465b7-b9bd-45d1-afe1-53224414acd9</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;I&amp;#39;ve reported your issue to the SDK developers, but It will take some time before they can look into it. We are nevertheless very greatful for your report.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/148410?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 12:35:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:831e27a9-64bf-4530-8a48-c0ea7ab878c3</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Just as a side comment, I am rather confident in the way that the TWI is configured, because I first did the experiment with two different peripherals, TWI1 and SPI0 and the legacy API. And in this case the TWI transfer works OK.&lt;/p&gt;
&lt;p&gt;My problem occurred after porting to the new API, and trying to use the PRS stuff to share TWI0 + SPI0.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/148409?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 12:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82d255f4-7077-44cd-a61e-5039148a8a74</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yes the NRF_PRS_BOX_0_ENABLED is set. This was anyway a good point to mention, as in the first place I did the mistake of not setting it. I have made a suggestion to &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/38206/improving-sdk_validation-h"&gt;improve the sdk_validation.h&lt;/a&gt;&amp;nbsp;to that respect.&lt;/p&gt;
&lt;p&gt;I think I have made some progress in understanding what happens.&lt;/p&gt;
&lt;p&gt;First of all the twi_irq_handler is not called, I have tried with a debugger and a JLink, with putting a breakpoint on this function.&lt;/p&gt;
&lt;p&gt;I also checked that p_cb-&amp;gt;handler and p_cb-&amp;gt;context are correctly set to my callback function (but anyway, that does not help as the irq handler is not called).&lt;/p&gt;
&lt;p&gt;Then, I saw that when nrfx_twi_xfer is called by my FreeRTOS task, it calls in turn twi_xfer, which in turn calls twi_tx_start_transfer. In twi_tx_start_transfer, p_cb-&amp;gt;int_mask is set to 0x286 which should be NRF_TWI_INT_STOPPED_MASK | NRF_TWI_INT_ERROR_MASK | NRF_TWI_INT_TXDSENT_MASK | NRF_TWI_INT_RXDREADY_MASK, and nrf_twi_int_enable(p_twi, p_cb-&amp;gt;int_mask) is called.&lt;/p&gt;
&lt;p&gt;However, I noticed that this call occurs after the call to (void)twi_send_byte(p_twi, p_data, length, &amp;amp;p_cb-&amp;gt;bytes_transferred, no_stop). Hopefully it is not too late, and the interrupt is still pending.&lt;/p&gt;
&lt;p&gt;Well, if there is any experiment (like reading some memory) you would like me to do, please feel free to ask !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/147801?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 12:26:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fc1130d-e12a-4fe7-b356-f92f39fa4407</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Have you set&amp;nbsp;&lt;a title="NRFX_PRS_BOX_0_ENABLED" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrfx__prs__config.html?cp=4_0_1_6_9_1_4_0_0#gad2d8ea78d999caa14bfb33a4baf67bc8"&gt;NRFX_PRS_BOX_X_ENABLED&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Another option is to uninitialize the TWI driver before initializing the SPI driver. If the both use the same instance number (0-2) they will in fact share the same peripheral and their drivers will not initialize unless the peripheral unless no other driver has claimed the instance. I believe this is what the PRS library does, only with semaphores and atomic operations. BOX 0 refers to SPIM0, SPIS0, TWIM0, TWIS0, SPI0, and TWI0.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/147234?ContentTypeID=1</link><pubDate>Tue, 04 Sep 2018 17:28:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb6bea3e-350f-421e-b6ac-e4b63a53b98d</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I tried to use the PRS library.&amp;nbsp;I ported my&amp;nbsp;entire peripheral chip handler&amp;nbsp;to the new API, so that one just have to set the NRFX_PRS_ENABLED flag for the nrfx_prs_acquire to be called under the hood by nrfx_twi_init. I am using SDK 15,0,0.&lt;/p&gt;
&lt;p&gt;It does not work for me, the call back passed to&amp;nbsp;nrfx_twi_init is never called, and after the first call to&amp;nbsp;nrfx_twi_xfer my OS task get stuck&amp;hellip;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/147043?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 17:38:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c226ec7-4ccf-4165-a102-eb2c9f6ff2d0</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;OK, after looking further into this matter, I sort of understood&amp;nbsp;that&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;either you use the nrfx_glue.h that is in the&amp;nbsp;nrf-sdk/integration/nrfx diretory, and then you use the legacy API and you have to call explicitly the nrfx_prs_acquire and nrfx_prs_release function.&lt;/li&gt;
&lt;li&gt;or you copy the nrfx_glue.h template from nrf-sdk/modules/nrfx/templates to some places where the FW can find it, and you use the new API. With the new API you do not need to call explicitly the nrfx_prs_&amp;hellip; stuff, because it does it by itself.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, my questions are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Have I understood well ?&lt;/li&gt;
&lt;li&gt;If yes, which way is better ?&lt;/li&gt;
&lt;li&gt;And, just to minimize the migration effort, is it possible to use the new API just for one peripheral and the legacy one for others, and in this case what care should be taken ?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/144680?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 10:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:104e2e4f-8912-40d0-8b7f-52a75ae742b3</guid><dc:creator>Vincent Bela&amp;#239;che</dc:creator><description>&lt;p&gt;Thank you for the answer, by reading the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk%2Fdita%2Fsdk%2Fnrf5_sdk.html"&gt;presentation&lt;/a&gt;&amp;nbsp;of this module, this seems to be the right answer&amp;hellip;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamic reconfiguration of peripheral HW from TWI to SPI</title><link>https://devzone.nordicsemi.com/thread/144678?ContentTypeID=1</link><pubDate>Fri, 17 Aug 2018 10:12:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97f0e327-05c8-4efa-b667-3f95ab283637</guid><dc:creator>mrono</dc:creator><description>&lt;p&gt;I think this should be doable with the SDK&amp;#39;s Peripheral Resource Sharing (PRS) module. If I have understood correctly the main purpose of the PRS module is to allow you to use shared resources like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>