<?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>Resetting Twim</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110159/resetting-twim</link><description>Hello, im trying to implement PingPong buffer( i guess that&amp;#39;s the name of mechanism ) 
 the way i have it currently done is. 
 Here comes the problem what should i do to reinitialize(if its needed) the twim instance with different buffer. should i just</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Apr 2024 14:25:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110159/resetting-twim" /><item><title>RE: Resetting Twim</title><link>https://devzone.nordicsemi.com/thread/479028?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 14:25:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a84be00-cd0a-4e00-829d-90881815b464</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Like I said in my previous answer, you need to provide a buffer every time you call&amp;nbsp;nrfx_twim_xfer(). If you are not using EasyDMA Arraylist feature, you can simply use a variable to keep track of the current buffer whenever it is called:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t tx_buffer[1] = {0x00};
static uint8_t rx_buffer1[8];
static uint8_t rx_buffer2[8];
static uint8_t current_buffer = 0;

static nrfx_twim_xfer_desc_t twim_xfer_desc1 = NRFX_TWIM_XFER_DESC_TXRX(BME280_I2C_ADDRESS, tx_buffer, 1, rx_buffer1, 8);
static nrfx_twim_xfer_desc_t twim_xfer_desc2 = NRFX_TWIM_XFER_DESC_TXRX(BME280_I2C_ADDRESS, tx_buffer, 1, rx_buffer2, 8);

void twim_transfer(void)
{
	if(current_buffer == 0)
	{
		nrfx_twim_xfer(&amp;amp;twim-&amp;gt;instance, &amp;amp;twim_xfer_desc1, NULL);
		current_buffer = 1;
	}
	else
	{
		nrfx_twim_xfer(&amp;amp;twim-&amp;gt;instance, &amp;amp;twim_xfer_desc2, NULL);
		current_buffer = 0;
	}
}

static void twim_handler(nrfx_twim_evt_t const *p_event, void *p_context)
{
	if(p_event-&amp;gt;type == NRFX_TWIM_EVT_DONE)
	{
		if(current_buffer == 0)
		{
			// process rx_buffer1
		}
		else
		{
			// process rx_buffer2
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I see that you have set&amp;nbsp;NRFX_TWIM_FLAG_RX_POSTINC/NRFX_TWIM_FLAG_REPEATED_XFER in your code, which relates to the EasyDMA ArrayList feature. However, your posted code does not include any details on the length of the RX in your transfer, how the&amp;nbsp;sensor_data_t type is declared, how next transfer is started, etc. If you are planning to use this, please include your full project in the ticket.&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: Resetting Twim</title><link>https://devzone.nordicsemi.com/thread/478837?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 18:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e077c0b-7961-43d7-833d-f7eaef817c46</guid><dc:creator>Dzolo2k1</dc:creator><description>&lt;p&gt;So I know the first section of ur reply. But im a bit confused right now. My question is still: what should I do to change buffers( 1 2 1 2 1 2 - thats the sequence i want to achieve ). I get first lets say 8 B then it is send to workQ where its used for some data processing, and the second buffer is already running, then it swaps again and again and again. How do i do it- there is no information about it in documentation that can help me.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resetting Twim</title><link>https://devzone.nordicsemi.com/thread/478813?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 14:17:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:754793f6-3a48-498d-9aad-932ea4033224</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Dzolo2k1"]I just want to have continous reading from TWIM without any delays, so i should just change&amp;nbsp;&lt;span&gt;&amp;nbsp;nrfx_twim_xfer_desc_t whenever 1 transfer is completed and that&amp;#39;s all?&lt;/span&gt;[/quote]
&lt;p&gt;The TWIM peripheral supports &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html#concept_cfw_vtp_xr"&gt;EasyDMA&lt;/a&gt;, which will transfer data directly from/to RAM without any CPU intervention. If you configure&amp;nbsp;&lt;span&gt;nrfx_twim_xfer_desc_t&amp;nbsp;to write one byte and read 8 bytes, this will happen automatically when the transfer is started, there is no need for the CPU to be involved. The lengths of the buffers should be decided the datasheet of the sensor that you are reading.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It is possible to switch buffers in HW&amp;nbsp;using the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/easydma.html#arraylist"&gt;EasyDMA ArrayList&lt;/a&gt; feature as well, if you want to do multiple transfers after each other without changing the buffers using the CPU, but this is more advanced.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resetting Twim</title><link>https://devzone.nordicsemi.com/thread/478554?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2024 12:45:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3aa68b0-4b6e-44b4-8bad-bff9c596d25c</guid><dc:creator>Dzolo2k1</dc:creator><description>&lt;p&gt;I just want to have continous reading from TWIM without any delays, so i should just change&amp;nbsp;&lt;span&gt;&amp;nbsp;nrfx_twim_xfer_desc_t whenever 1 transfer is completed and that&amp;#39;s all? In pseudo code if would be like this:&lt;br /&gt;&lt;br /&gt;- If counter &amp;gt;=8&amp;nbsp; submit to queue with old buffer and change nrfx_twim_xfer_desc_t to new buffer?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Resetting Twim</title><link>https://devzone.nordicsemi.com/thread/478439?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2024 06:46:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4d282ac-406c-45bc-b823-b7e955f69cd1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You provide new buffer pointer every time you call&amp;nbsp;nrfx_twim_xfer(), both for TX and RX buffers. If you want to swap between two different sets of buffers, you can define two&amp;nbsp;nrfx_twim_xfer_desc_t objects to pass to&amp;nbsp;&lt;span&gt;nrfx_twim_xfer(). Once you call this function, the transfer will start (since you are the master), and the buffers will be clocked out/filled, based on the requested transfer lengths. When the transfer is completed, the buffers are free to be reused or processed. It is not necessary to disable to uninit the TWIM driver to swap the buffers, when you start a new transfer by calling&amp;nbsp;nrfx_twim_xfer(), new buffers can be provided. If you want to switch buffers in the middle of a transfer for some reason, you should first wait for the previous transfer to complete by waiting for the&amp;nbsp;NRFX_TWIM_EVT_DONE before starting a new transfer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>