<?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>How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88277/how-to-transfer-large-amounts-of-data-over-i2c</link><description>Hello, 
 
 I am using the vl53l5cx TOF sensor and implementing the ULD using zephyr. My setup is a bl654 board using zephyr on sdk 1.9.1. However I am running into an issue, since the sensor is RAM based in the init() it&amp;#39;s required to upload ~82kB of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Jul 2022 21:49:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88277/how-to-transfer-large-amounts-of-data-over-i2c" /><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/377733?ContentTypeID=1</link><pubDate>Tue, 19 Jul 2022 21:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fcf5c19-1663-4b58-8c0d-aaef4dff458f</guid><dc:creator>tekochip</dc:creator><description>&lt;p&gt;I had gotten a confirmation from ST and got mine running with smaller blocks yesterday.&amp;nbsp; With smaller blocks you will not need to alter Zephyr&amp;#39;s I2C timeout, but the stack usage is still a real issue when running the demos.&amp;nbsp; It&amp;#39;s probably best to make the device and results variables static.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/377716?ContentTypeID=1</link><pubDate>Tue, 19 Jul 2022 17:50:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69d26b3a-ec0d-4a20-b539-d05868f9a7fb</guid><dc:creator>jspiller</dc:creator><description>&lt;p&gt;Yes I struggled with this as well mostly because it was poorly documented in the datasheet for the sensor. You can break it up you just need to increment the register address accordingly to every transfer. I have it working with zephyr so let me know if need any help.&lt;/p&gt;
&lt;p&gt;-Jacob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/377479?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2022 22:12:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce428c35-8cd2-4ece-8539-7c6521f36596</guid><dc:creator>tekochip</dc:creator><description>&lt;p&gt;I stand corrected, you CAN break the transfer into smaller blocks and the firmware WILL load properly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/377274?ContentTypeID=1</link><pubDate>Sat, 16 Jul 2022 13:45:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcea90e6-6213-4aa0-82ca-aa37e028782e</guid><dc:creator>tekochip</dc:creator><description>&lt;p&gt;Oh, one last thing.&amp;nbsp; The Zephyr I2C driver has a timeout that you&amp;#39;ll need to extend.&amp;nbsp; I set mine for 1000ms.&amp;nbsp; Without the change the driver will kill the transfer after 500ms.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;I2C_TRANSFER_TIMEOUT_MSEC&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;K_MSEC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1000&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/377258?ContentTypeID=1</link><pubDate>Fri, 15 Jul 2022 20:28:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58a4cf33-eaac-4a17-b973-574df7d6a194</guid><dc:creator>tekochip</dc:creator><description>&lt;p&gt;Don&amp;#39;t be tempted to break the transfer into smaller blocks, because the ST sensor will not run properly if you do.&amp;nbsp; The main trick is that the DMA cannot handle transfers from FLASH, you must first copy the transfer to RAM.&amp;nbsp; The next trick is that this will result in a stack size that is far too large, so you need to make the buffer static:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;uint8_t WrMulti(&lt;/code&gt;&lt;br /&gt;&lt;code&gt; VL53L5CX_Platform *p_platform,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint16_t RegisterAdress,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint8_t *p_values,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint32_t size)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;uint8_t status=VL53L5CX_STATUS_OK;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; static uint8_t localBuf[0x8002];&lt;/code&gt;&lt;br /&gt; &lt;br /&gt;&lt;code&gt; localBuf[0] = RegisterAdress/256;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localBuf[1] = RegisterAdress;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; memcpy(&amp;amp;localBuf[2], p_values, size);&lt;/code&gt;&lt;br /&gt; &lt;br /&gt;&lt;code&gt; /* Need to be implemented by customer. This function returns 0 if OK */&lt;/code&gt;&lt;br /&gt;&lt;code&gt; status |= i2c_write(p_platform-&amp;gt;i2c, localBuf, size+2, p_platform-&amp;gt;address);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;code&gt; return status;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Lastly, the examples from ST often require too much stack space.&amp;nbsp; This will frustrate you because the error will not occur when the offending function is started, it will fail when you attempt to use a variable inside the function, or called from that function.&amp;nbsp; You need to make their local variables static, so in example1(), make these static:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;VL53L5CX_Configuration&lt;/span&gt;&lt;span&gt; &amp;nbsp; &lt;/span&gt;&lt;span&gt;Dev&lt;/span&gt;&lt;span&gt; ;&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Sensor configuration */&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;VL53L5CX_ResultsData&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;Results&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Results data from VL53L5CX */&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;/p&gt;
I also have this running with Nordic&amp;#39;s SDK.&amp;nbsp; That requires some coding outside of Nordic&amp;#39;s API because the function only has an 8-bit size, but the driver can handle 16 bits.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;uint8_t WrMulti(&lt;/code&gt;&lt;br /&gt;&lt;code&gt; VL53L5CX_Platform *p_platform,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint16_t RegisterAdress,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint8_t *p_values,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint32_t size)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt; int32_t status_int;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint8_t status = VL53L5CX_STATUS_OK;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; uint8_t localBuf[size + 2];&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; /* Need to be implemented by customer. This function returns 0 if OK */&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; /*Copy from FLASH into RAM, as required by EasyDMA, and create address in first two bytes*/&lt;/code&gt;&lt;br /&gt;&lt;code&gt; memcpy(&amp;amp;localBuf[2], p_values, size);&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localBuf[0] = RegisterAdress / 256;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; localBuf[1] = RegisterAdress;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; /*Wait for any current operations*/&lt;/code&gt;&lt;br /&gt;&lt;code&gt; while (nrf_drv_twi_is_busy(p_platform-&amp;gt;i2c));&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; /*Create TWIM descriptor to get larger than 8 bit size, must be constant*/&lt;/code&gt;&lt;br /&gt;&lt;code&gt; nrfx_twim_xfer_desc_t const twim_xfer_desc =&lt;/code&gt;&lt;br /&gt;&lt;code&gt; {&lt;/code&gt;&lt;br /&gt;&lt;code&gt; .type = (nrfx_twim_xfer_type_t)NRF_DRV_TWI_XFER_TX,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; .address = p_platform-&amp;gt;address,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; .primary_length = size + 2,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; .p_primary_buf = localBuf,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; };&lt;/code&gt;&lt;br /&gt;&lt;code&gt; status = nrfx_twim_xfer(&amp;amp;p_platform-&amp;gt;i2c-&amp;gt;u.twim, &amp;amp;twim_xfer_desc, 0);&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; while (nrf_drv_twi_is_busy(p_platform-&amp;gt;i2c));&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt; return status;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;I&amp;nbsp;was frustrated for days by this, so I hope I&amp;#39;ve been able to help somebody else in trouble.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to transfer large amounts of data over I2C</title><link>https://devzone.nordicsemi.com/thread/369542?ContentTypeID=1</link><pubDate>Wed, 25 May 2022 13:02:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cd492ef-0c93-4c4c-a0d5-0ef4f3ed5265</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suggest to get a logic analyzer trace and see the data transferred on the twi bus, then you can also see the start, and re-start bits, and the device address and if the register address are incremented as expected. Alternatively you need to write it on byte level using direct address access, something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/28367/i2c-driver-from-scratch-using-direct-register-access"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/28367/i2c-driver-from-scratch-using-direct-register-access&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>