<?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>Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1</link><description>While trying to communicate through I2C/TWI with a MCP39F521 using a NRF52 DK (NRF52832), the first bit of the received data is always 1. The NRF52 DK is the TWI Master and the MCP39F521 is the TWI slave. 
 According to the MCP39F521 datasheet , the first</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Sep 2020 13:59:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1" /><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/267878?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 13:59:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:226576ce-fdfa-4b1e-bd60-bd8c553e6b30</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;As far as I know, this is not fixed on nRF52833. See the following note in the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/twim.html"&gt;product specifications&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;This TWI master supports clock stretching performed by the slaves. Note that the SCK pulse following a stretched clock cycle may be shorter than specified by the I2C specification.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This note is not included in the nRF52832 PS, hence the need for the errata.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/267874?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 13:42:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f4998bc-6040-4c7d-bf5a-19284bea7f07</guid><dc:creator>EddyB</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;We have exactly the same problem and when scoping it is very clear to us that the Errata 149, being the incorrect first clock after the clock stretching, causes the problem.&amp;nbsp; Since there is apparently no solution with the nRF52832, we are considering moving to the nRF52833.&lt;br /&gt;Can you please confirm that this issue has been resolved in the nRF52833?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/266729?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 12:20:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7b86f99-9c02-494b-a1e2-bb92008d849a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Pedro Martins"]What is shown is that the short starts the RX transfer immediately&amp;nbsp;after the TX. This might be a problem if the master ignores clock stretching. Is that the case?[/quote]
&lt;p&gt;As far as I know, the master will not ignore clock stretching from the slave. All clock stretching shown in the diagrams are performed by the master itself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/260399?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2020 13:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5eba0609-041a-4293-a216-07dd0f8bbc0f</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Thank you for the quick response &lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt;, but I don&amp;#39;t understand what you mean by:&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/260333"]will actually generate a repeated start condition and not just avoid the STOP condition[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html?cp=4_0_0_5_30"&gt;TWI interface is&amp;nbsp;compatible with the I2C protocol&lt;/a&gt;&amp;nbsp;and to the best of my knowledge, a repeated start is when the master initiates a new transaction on the bus without&amp;nbsp;finishing the previous transaction, i.e., without sending a stop condition. Therefore, not sending a stop condition and sending a repeated start refer to the same behavior. Please advise&amp;nbsp;if&amp;nbsp;there is something I am missing on my understanding.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Regarding the shortcut between the&amp;nbsp;&lt;span&gt;LASTTX-&amp;gt;STARTRX, I looked at the TWIM diagrams. What is shown is that the short starts the RX transfer immediately&amp;nbsp;after the TX. This might be a problem if the master ignores clock stretching. Is that the case?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html?cp=4_0_0_5_30_3#concept_ebf_cwp_xr__fig.complex"&gt;on the diagram below&lt;/a&gt;&amp;nbsp;to the one you provided, clock stretching is shown when using a TXRX transfer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To summarize, my question is: Does using a TXRX transfer causes the master to not accept/ignore clock stretching by the slave?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/260333?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2020 10:27:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:143aff62-a4f6-456a-982e-b027e09c2b50</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I checked the documentation again, and it looks like the LASTTX-&amp;gt;STARTRX short, which are &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v1.8.4/drivers/src/nrfx_twim.c#L459"&gt;used in the TXRX case in nrfx_twim&lt;/a&gt;, will actually generate a repeated start condition and not just avoid the STOP condition. See the diagram in&amp;nbsp;&lt;a title="Master repeated start sequence" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html?cp=4_0_0_5_30_3#concept_ebf_cwp_xr"&gt;Master repeated start sequence&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/260329?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2020 10:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbfd3daa-1961-43ea-af04-d059dbaa6812</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Thank you for the clarification, &lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;From the TWIM documentation, I was expecting&amp;nbsp;the behavior you described in the usage of&amp;nbsp;the flags and transfer types.&lt;/p&gt;
&lt;p&gt;However, note that sending a TX transfer without a stop condition and&amp;nbsp;immediately after&amp;nbsp;sending a RX transfer results&amp;nbsp;in the data being correctly received from the slave,&amp;nbsp;while sending a TXRX doesn&amp;#39;t&amp;nbsp;get me&amp;nbsp;any data&amp;nbsp;in the secondary buffer.&lt;/p&gt;
&lt;p&gt;So, the fact that a STOP condition is not being generated does not seem to affect the behavior of the slave, otherwise, to my understanding, it wouldn&amp;#39;t work on a TX with no stop condition + RX communication.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are&amp;nbsp;there any other differences&amp;nbsp;between a TX+RX and a TXRX transfer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/260318?ContentTypeID=1</link><pubDate>Thu, 16 Jul 2020 09:30:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebb286a7-d74c-48fa-b006-33a2d77a18b4</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The difference between using&amp;nbsp;NRFX_TWIM_XFER_DESC_TXRX and separate&amp;nbsp;NRFX_TWIM_XFER_DESC_TX/RX is that the first option will by default not generate a STOP condition between the TX and RX operations, while the second option will generate a STOP condition. It can be that the slave device you are using is expecting a STOP condition in this case, meaning that the&amp;nbsp;NRFX_TWIM_XFER_DESC_TXRX option will not work.&lt;/p&gt;
&lt;p&gt;A transfer with&amp;nbsp;NRFX_TWIM_XFER_DESC_TX can take a flag (&lt;span&gt;NRFX_TWIM_FLAG_TX_NO_STOP) to also not generate a STOP condition, but there is no similar flag for&amp;nbsp;NRFX_TWIM_XFER_DESC_TXRX&amp;nbsp;to force a STOP condition between the transfers.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/260228?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 18:17:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38ca2ca5-9e17-432b-a5c1-ab269773180e</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt;,&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259860"] Some &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v1.8.4/CHANGELOG.md#182---2020-03-05"&gt;fixes were introduced in nrfx v1.8.2&lt;/a&gt; and should be included in nRF5 SDK v17.0.0 (which uses nrfx v1.8.4). Can you try to update to the latest SDK, to see if this solves some of your issues?[/quote]
&lt;p&gt;Thank you for the suggestion. I successfully migrated from the NRF5 SDK version 16.0.0 to 17.0.0, to update the nfrx drivers.&lt;/p&gt;
&lt;p&gt;The behavior described in my message above (the&amp;nbsp;&lt;span&gt;nrfx_twim_xfer stays&amp;nbsp;stuck&amp;nbsp;on a TXRX transfer), is solved, since the transfer either successfully&amp;nbsp;or unsuccessfully&amp;nbsp;finishes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, when doing a TXRX transfer, the RX buffer is empty, i.e., no data was read from the slave. This behavior occurs either if I set up the TWIM module to&amp;nbsp;operate in a blocking or non-blocking mode. An example of a TXRX transfer is below:&lt;pre class="ui-code" data-mode="c_cpp"&gt;// partially Init Array (Checksum field not initialized)
cmd_frame2[0] = MCP39F521_HEADER_BYTE;
cmd_frame2[1] = REG_READ_CMD_N_BYTES;
cmd_frame2[2] = MCP39F521_SET_ADR_PTR_INSTR;
cmd_frame2[3] = (reg_address &amp;amp; LEFTMOST_BYTE_BIT_MASK) &amp;gt;&amp;gt; BYTE_SHIFT;
cmd_frame2[4] = reg_address &amp;amp; RIGHTMOST_BYTE_BIT_MASK;
cmd_frame2[5] = MCP39F521_REG_READ_INSTR;
cmd_frame2[6] = n_bytes;

uint8_t bytes = n_bytes + MCP39F521_RESPONSE_BASE_N_BYTES;
cmd_frame2[REG_READ_CMD_N_BYTES - 1] = __compute_byte_addition_checksum(cmd_frame2);      // Compute Command Checksum

nrfx_twim_xfer_desc_t txrx_xfer = NRFX_TWIM_XFER_DESC_TXRX(MCP39F521_BASE_ADDRESS, cmd_frame2, REG_READ_CMD_N_BYTES, rx_data, bytes);

err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;txrx_xfer, 0);
if (err_code != NRF_SUCCESS) {
  NRF_LOG_DEBUG(&amp;quot;TX Error Code: %d&amp;quot;, err_code);
}


&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Nonetheless, if I split the TXRX transfer into a TX and a RX transfer, either using the TWIM module in&amp;nbsp;blocking or non-blocking configurations, the RX buffer successfully&amp;nbsp;contains the device response.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// partially Init Array (Checksum field not initialized)
cmd_frame2[0] = MCP39F521_HEADER_BYTE;
cmd_frame2[1] = REG_READ_CMD_N_BYTES;
cmd_frame2[2] = MCP39F521_SET_ADR_PTR_INSTR;
cmd_frame2[3] = (reg_address &amp;amp; LEFTMOST_BYTE_BIT_MASK) &amp;gt;&amp;gt; BYTE_SHIFT;
cmd_frame2[4] = reg_address &amp;amp; RIGHTMOST_BYTE_BIT_MASK;
cmd_frame2[5] = MCP39F521_REG_READ_INSTR;
cmd_frame2[6] = n_bytes;

uint8_t bytes = n_bytes + MCP39F521_RESPONSE_BASE_N_BYTES;
cmd_frame2[REG_READ_CMD_N_BYTES - 1] = __compute_byte_addition_checksum(cmd_frame2);      // Compute Command Checksum

nrfx_twim_xfer_desc_t tx_xfer = NRFX_TWIM_XFER_DESC_TX(MCP39F521_BASE_ADDRESS, cmd_frame2, REG_READ_CMD_N_BYTES);
nrfx_twim_xfer_desc_t rx_xfer = NRFX_TWIM_XFER_DESC_RX(MCP39F521_BASE_ADDRESS, rx_data, bytes);

err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;tx_xfer, 0);
if (err_code != NRF_SUCCESS) {
  NRF_LOG_DEBUG(&amp;quot;TX Error Code: %d&amp;quot;, err_code);
}


err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;rx_xfer, 0 );
if (err_code != NRF_SUCCESS) {
  NRF_LOG_DEBUG(&amp;quot;TX Error Code: %d&amp;quot;, err_code);
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrfx__twim.html?cp=7_1_6_8_0_39_0_20_2#ggaee5cd6cb780546f1b40e0d7dd741a37fa89736f2c78e463456126da975d806a3a"&gt;TXRX transfer sends a Repeated Start&lt;/a&gt; instead of a Start + Stop bit, I have also tested sending a TX transfer with a repeated start, using the&amp;nbsp;NRFX_TWIM_FLAG_TX_NO_STOP, and then performing the RX transfer. For that, I changed the line&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;tx_xfer, 0);&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;to&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;tx_xfer, NRFX_TWIM_FLAG_TX_NO_STOP);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And successfully&amp;nbsp;received the expected data response on the RX buffer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please consider that when I am enabling the non-blocking mode, I add a while loop after each nrfx_twim_xfer call. This loop waits for a flag variable that is toggled on the twim callback&amp;nbsp;routine when the NRFX_TWIM_EVT_DONE occurs. This implementation is to simplify testing and is similar to the twim_sensor example.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you&amp;nbsp;&lt;/span&gt;&lt;span&gt;provide info&amp;nbsp;about this recent issue?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also, why does a TX transfer with repeated start + a RX transfer succeeds&amp;nbsp;and retrieves the correct data and a TXRX transfer does not?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please notice that the underlying issue, the &amp;quot;Most Significative Bit in TWIM RX transfer is always 1&amp;quot;, still occurs.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your time and help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259860?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 09:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9f00d46-88a9-4e0a-ac0d-b49c765f7f34</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I think that could happen with older driver versions if the slave is misbehaving. Some &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v1.8.4/CHANGELOG.md#182---2020-03-05"&gt;fixes were introduced in nrfx v1.8.2&lt;/a&gt; and should be included in nRF5 SDK v17.0.0 (which uses nrfx v1.8.4). Can you try to update to the latest SDK, to see if this solves some of your issues?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259272?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 16:44:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc686b92-c213-42f2-8a85-6308417789ec</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;I recognize that not having the scope available makes more difficult to figure this one out.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259247"]As far as I know, handling of clock stretching performed by the TWI slave is handled purely in HW. There are no timeouts in the driver, so it should always wait for either a STOPPED or ERROR event to be generated (or SUSPENDED&amp;nbsp;event in case of TX without STOP condition)[/quote]
&lt;p&gt;Regarding the driver timeouts, if the&amp;nbsp;&amp;quot;managing&amp;quot;&amp;nbsp;of the clock stretch is fully performed by the HW and if I fully understood the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__twim.html"&gt;TWIM driver documentation&lt;/a&gt;, then:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I should use the&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__twim.html#gae53a1bebcd5961e1cd7a79e4039b8c88"&gt;nrfx_twim_xfer&lt;/a&gt;&amp;nbsp;to send a transfer;&lt;/li&gt;
&lt;li&gt;In my case, since I want to performed a write followed by a read, I should use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__twim.html#ggaee5cd6cb780546f1b40e0d7dd741a37fa89736f2c78e463456126da975d806a3a"&gt;NRFX_TWIM_XFER_DESC_TXRX&lt;/a&gt; macro to encapsulate the data to be sent&lt;/li&gt;
&lt;li&gt;The data buffers p_tx and r_tx on the transfer descriptor should reside .data memory section of RAM, since the TWIM driver uses EasyDMA.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If this is true, consider that I do not use an event handler and want a blocking transfer. My TWIM config&amp;nbsp;would be the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void twim_init (void)
{
    ret_code_t err_code;

    const nrfx_twim_config_t twim_config = {
       .scl                 = ARDUINO_SCL_PIN,
       .sda                 = ARDUINO_SDA_PIN,
       .frequency           = NRF_TWIM_FREQ_100K,
       .interrupt_priority  = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY,
       .hold_bus_uninit     = NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    };

    err_code = nrfx_twim_init(&amp;amp;m_twi_master, &amp;amp;twim_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrfx_twim_enable(&amp;amp;m_twi_master);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and I am executing the transfer by doing the following (cmd_frame2 is formatted to be a valid MCP39F521. More info on the MCP39F521 datasheet)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  // Init cmd_frame2, a global variable array
  cmd_frame2[0] = MCP39F521_HEADER_BYTE;
  cmd_frame2[1] = REG_READ_CMD_N_BYTES;
  cmd_frame2[2] = MCP39F521_SET_ADR_PTR_INSTR;
  cmd_frame2[3] = (reg_address &amp;amp; LEFTMOST_BYTE_BIT_MASK) &amp;gt;&amp;gt; BYTE_SHIFT;
  cmd_frame2[4] = reg_address &amp;amp; RIGHTMOST_BYTE_BIT_MASK;
  cmd_frame2[5] = MCP39F521_REG_READ_INSTR;
  cmd_frame2[6] = n_bytes;

  // Number of bytes required on the response
  uint8_t bytes = n_bytes + MCP39F521_RESPONSE_BASE_N_BYTES;
  
  // Compute Command Checksum
  cmd_frame2[REG_READ_CMD_N_BYTES - 1] = __compute_byte_addition_checksum(cmd_frame2);      

  nrfx_twim_xfer_desc_t txrx_xfer = NRFX_TWIM_XFER_DESC_TXRX(MCP39F521_BASE_ADDRESS, cmd_frame2, REG_READ_CMD_N_BYTES, rx_data, bytes);

  err_code = nrfx_twim_xfer(g_mcp39f521_twim_instance, &amp;amp;txrx_xfer, 0  );&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, I should expect&amp;nbsp;nrfx_twim_xfer to either finish the transfer successfully or return an error code, correct?&amp;nbsp;However the call to nrfx_twim_xfer never returns.&lt;/p&gt;
&lt;p&gt;Debugging, I am stuck on the while loop on line 523, on nrfx_twim.c, which is the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        while (!nrf_twim_event_check(p_twim, evt_to_wait))
        {
            if (nrf_twim_event_check(p_twim, NRF_TWIM_EVENT_ERROR))
            {
                NRFX_LOG_DEBUG(&amp;quot;TWIM: Event: %s.&amp;quot;, EVT_TO_STR_TWIM(NRF_TWIM_EVENT_ERROR));
                nrf_twim_event_clear(p_twim, NRF_TWIM_EVENT_ERROR);
                nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_RESUME);
                nrf_twim_task_trigger(p_twim, NRF_TWIM_TASK_STOP);
                evt_to_wait = NRF_TWIM_EVENT_STOPPED;
            }
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is my reasoning correct? If so, what am I missing on the driver and TWIM module behavior?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259247?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 14:30:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b12af7b-0112-481c-a2f7-a798931a8fcb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Pedro Martins"]Regarding clock stretching, can you please inform how well are the twim drivers &amp;quot;prepared to deal with with&amp;quot;?[/quote]
&lt;p&gt;As far as I know, handling of clock stretching performed by the TWI slave is handled purely in HW. There are no timeouts in the driver, so it should always wait for either a STOPPED or ERROR event to be generated (or SUSPENDED&amp;nbsp;event in case of TX without STOP condition). It would really help if you could get some logic traces of the bus to see what is actually going on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259149?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 11:11:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe9e7dc8-9ad9-4ba9-9a52-80aa7bb9e220</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Thank you for the suggestions &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regarding the internal pull-up values, the Arduino Uno uses&amp;nbsp;20 k&lt;span&gt;&amp;Omega; and the NRF52 DK 13 k&amp;Omega;. Since I am using the &lt;a href="https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/ADM00686"&gt;MCP39F521 Development Kit&lt;/a&gt;, it has &lt;a href="http://ww1.microchip.com/downloads/en/DeviceDoc/ADM00686%20Rev%201%20Schematics.PDF"&gt;2.1 k&amp;Omega; pull-ups&lt;/a&gt; on the I2C lines. This yields&amp;nbsp;the total pull-up resistors for the Arduino setup to be 1.9 k&amp;Omega; and 1.8 k&amp;Omega; for the NRF52 DK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have also tried using only the&amp;nbsp;&lt;a href="https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/ADM00686"&gt;MCP39F521 Development Kit&lt;/a&gt;, pull ups, i.e., disabling the NRF52 DK internal pull-ups, but the result is the same (as would be expected, since the total pull-up values are very similar)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="65515" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259055"]I would also try H0D1 settings for both SDA and SCL pins[/quote]
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;The stronger low driver makes sense. I changed the GPIO drive mode to the High-Drive &amp;#39;0&amp;#39;, but the result stays the same.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259144?ContentTypeID=1</link><pubDate>Thu, 09 Jul 2020 10:30:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1e72082-054c-45a4-9779-cfcde6cef25f</guid><dc:creator>martinspedro</dc:creator><description>[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259017"]Your reasoning sounds plausible, but it would really help if you could get logic/scope traces of the bus to determine if this could be what is happening.[/quote]
&lt;p&gt;Thank you for confirming &lt;a href="https://devzone.nordicsemi.com/members/jorgen"&gt;Jørgen&lt;/a&gt;. I am trying to get my hands on a scope/logic analyzer. If I can get one during the next week, I update my answer with scopes.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259017"]t is strange if you see this every time if it is related to clock stretching unless the slave performs clock stretching on every transfer.&amp;nbsp;[/quote]
&lt;p&gt;From my understanding of the &lt;a href="http://ww1.microchip.com/downloads/en/DeviceDoc/20005442A.pdf"&gt;MCP39F521 datasheet&lt;/a&gt;, this is indeed true. The device performs clock stretching on every transfer. Regarding clock stretching, can you please inform how well are the twim drivers &amp;quot;prepared to deal with with&amp;quot;?&lt;/p&gt;
&lt;p&gt;I noticed several&amp;nbsp;failed reads from the NRF52 DK and it seems that the MCU fails to wait for a response of the MCP39F521. This behavior happens on blocking and non-blocking mode and results on NRF_ERROR_INTERNAL or NRF_DEVICE_NACK.&lt;/p&gt;
&lt;p&gt;Also, despite the device supporting up to 400 kHz, the MCU only receives &amp;quot;garbage data&amp;quot; if the line is configured to 250 or 400 kHz.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/63519/most-significative-bit-in-twim-rx-transfer-is-always-1/259017"]Have you tried other slaves to see if they experience the same behavior?[/quote]
&lt;p&gt;Not yet, but I will during the following days.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259055?ContentTypeID=1</link><pubDate>Wed, 08 Jul 2020 23:03:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a372357-48b2-4264-a22c-35a41d4645ff</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Long shot, but try comparing the total pull-up resistance between the DK and the Arduino (parallel combo of board and sensor board); if they are the same then this isn&amp;#39;t an issue.&lt;/p&gt;
&lt;p&gt;I would also try H0D1 settings for both SDA and SCL pins. This is the default:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define TWIM_PIN_INIT(_pin) nrf_gpio_cfg((_pin),                     \
                                         NRF_GPIO_PIN_DIR_INPUT,     \
                                         NRF_GPIO_PIN_INPUT_CONNECT, \
                                         NRF_GPIO_PIN_PULLUP,        \
                                         NRF_GPIO_PIN_S0D1,          \
                                         NRF_GPIO_PIN_NOSENSE)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This would be better&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define TWIM_PIN_INIT(_pin) nrf_gpio_cfg((_pin),                     \
                                         NRF_GPIO_PIN_DIR_INPUT,     \
                                         NRF_GPIO_PIN_INPUT_CONNECT, \
                                         NRF_GPIO_PIN_PULLUP,        \
                                         NRF_GPIO_PIN_H0D1,          \
                                         NRF_GPIO_PIN_NOSENSE)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The H0D1 can also be set after the i2c has been initialised using the io pin setup. The reason for trying this change is that weak clock drive can affect timing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Most Significative Bit in TWIM RX transfer is always 1</title><link>https://devzone.nordicsemi.com/thread/259017?ContentTypeID=1</link><pubDate>Wed, 08 Jul 2020 14:05:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:573e36a5-cc48-47a0-aeef-91d5cfef6032</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Your reasoning sounds plausible, but it would really help if you could get logic/scope traces of the bus to determine if this could be what is happening. It is strange if you see this every time if it is related to clock stretching unless the slave performs clock stretching on every transfer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tried other slaves to see if they experience the same behavior?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>