<?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>Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99058/using-the-nrfx_twim-h-to-develop-a-simple-i2c-communicate-code</link><description>Hi, 
 I&amp;#39;m working on a project and I need to develop a code to communicate nRF52840 with a GPS module (Ublox MAX-M10S - address 0x42) over I2C. I don&amp;#39;t finded anyone example to do this, so I&amp;#39;m trying to develop a I2C librarie (similar the WIRE.H, used</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Apr 2023 07:37:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99058/using-the-nrfx_twim-h-to-develop-a-simple-i2c-communicate-code" /><item><title>RE: Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/thread/422435?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2023 07:37:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22a7b7c3-45f8-4bff-a320-47b13628959b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Agnaldo Pagano"]&lt;p&gt;Thanks,&amp;nbsp;but my idea is to develop a librarie, similar the Wire.h, used for ESP32, for example. Therefore, I need to use nrfx_twim.h to execute the calls, like nrfx_twim_init(), and the functions to write and read information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My question would be if I need to define the pins I&amp;#39;m going to use (SDA and SCL) in the device tree, the same way I do using the &amp;#39;drivers/i2c.h&amp;#39; library, as in the example. Or if I need to set in another location.&lt;/p&gt;[/quote]
&lt;p&gt;You need to port that specific library to match the driver you choose.&lt;/p&gt;
&lt;p&gt;with nrfx, you do not need to define pins directly in DT, as the SDA/SCL are provided as input for the init-function (type &amp;quot;&lt;span&gt;nrfx_twim_config_t&amp;quot;)&lt;/span&gt;.&lt;/p&gt;
[quote user="Agnaldo Pagano"]Could you explain to me the difference between these two libraries? (&amp;#39;nrfx_twim.h&amp;#39; and &amp;#39;drivers/i2c.h&amp;#39;)[/quote]
&lt;p&gt;nrfx is the driver HAL, while i2c is the generic zephyr&amp;nbsp;driver, which also uses nrfx under-the-hood for nRF devices.&lt;/p&gt;
&lt;p&gt;By using the&amp;nbsp;zephyr i2c driver,&amp;nbsp;you can also add any sensor that zephyr rtos already has added support for.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/thread/422326?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 13:57:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70ec0f15-37d5-48aa-a030-4d5a970c6675</guid><dc:creator>Agnaldo Pagano</dc:creator><description>[quote userid="2115" url="~/f/nordic-q-a/99058/using-the-nrfx_twim-h-to-develop-a-simple-i2c-communicate-code/422319"]Do you need to communicate with a i2c slave? If yes, then you need to implement a i2c master (TWIM).[/quote]
&lt;p&gt;Yes, I need to communicate with a GPS module, to read geo data.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="2115" url="~/f/nordic-q-a/99058/using-the-nrfx_twim-h-to-develop-a-simple-i2c-communicate-code/422319"]&lt;p&gt;That is completely up to you, if you want to use &amp;quot;nrfx&amp;quot; directly or the i2c driver from zephyr.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a guide from our nordic academy on this exact setup:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.nordicsemi.com/lessons/lesson-6-serial-com-i2c/"&gt;https://academy.nordicsemi.com/lessons/lesson-6-serial-com-i2c/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I would recommend that you have a look at that as a reference.&lt;/p&gt;[/quote]
&lt;p&gt;Thanks,&amp;nbsp;but my idea is to develop a librarie, similar the Wire.h, used for ESP32, for example. Therefore, I need to use nrfx_twim.h to execute the calls, like nrfx_twim_init(), and the functions to write and read information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My question would be if I need to define the pins I&amp;#39;m going to use (SDA and SCL) in the device tree, the same way I do using the &amp;#39;drivers/i2c.h&amp;#39; library, as in the example. Or if I need to set in another location.&lt;br /&gt;In my code, I need to define these SDA and SCL pins as GPIO, right?&lt;/p&gt;
&lt;p&gt;Could you explain to me the difference between these two libraries? (&amp;#39;nrfx_twim.h&amp;#39; and &amp;#39;drivers/i2c.h&amp;#39;)&lt;/p&gt;
[quote userid="2115" url="~/f/nordic-q-a/99058/using-the-nrfx_twim-h-to-develop-a-simple-i2c-communicate-code/422319"]Please also note that your targeted external device seems to also support using UART.[/quote]
&lt;p&gt;Yes, but for my application I need it to be I2C communication.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/thread/422319?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 13:40:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1805aa9-bcc7-45b2-a74c-c49c2fc6ddd1</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Agnaldo Pagano"]I was a little in doubt about the operation and what the TWIM and TWIS libraries are for, that is, what differentiates between them besides the nomenclature. In the example I saw (hal_nordic/nrfx/samples/src/nrfx_twim_twis/txrx/main.c), information is read from a drone. Why is TWIM and TWIS used? Wouldn&amp;#39;t it be possible to use only TWIM to read information from the drone? That is, make the TWI communication with the drone using only the nrfx_twim.h library?[/quote]
&lt;p&gt;It shows both a master (TWIM) and a slave (TWIS) implementation, so that you can connect both and see that they communicate over each respective bus. You can read more about this in the respective readme.md file.&lt;/p&gt;
[quote user="Agnaldo Pagano"]I ask these questions because for my project, I need to communicate with the module using the nrfx libraries, so I would like to know if I will need to use only nrfx_twim.h or will I need to use both, as in the example.[/quote]
&lt;p&gt;Do you need to communicate with a i2c slave? If yes, then you need to implement a i2c master (TWIM).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Agnaldo Pagano"]Another question, I am using nRF Connect SDK, in this example that I need to use the TWIM driver, do I need to define the pins used in the .overlay file? As in the examples that use I2C communication using the zephyr/drivers/i2c library, in which I define the SDA and SCL pins in the .overlay file.&lt;br /&gt;What parameters do I have to define in the prj.conf file?[/quote]
&lt;p&gt;That is completely up to you, if you want to use &amp;quot;nrfx&amp;quot; directly or the i2c driver from zephyr.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a guide from our nordic academy on this exact setup:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://academy.nordicsemi.com/lessons/lesson-6-serial-com-i2c/"&gt;https://academy.nordicsemi.com/lessons/lesson-6-serial-com-i2c/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I would recommend that you have a look at that as a reference.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please also note that your targeted external device seems to also support using UART.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/thread/422275?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 11:56:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2749348-345d-4422-8b3c-26739a154e7d</guid><dc:creator>Agnaldo Pagano</dc:creator><description>&lt;p&gt;Hi, thanks for the example!&lt;br /&gt;I was a little in doubt about the operation and what the TWIM and TWIS libraries are for, that is, what differentiates between them besides the nomenclature. In the example I saw (hal_nordic/nrfx/samples/src/nrfx_twim_twis/txrx/main.c), information is read from a drone. Why is TWIM and TWIS used? Wouldn&amp;#39;t it be possible to use only TWIM to read information from the drone? That is, make the TWI communication with the drone using only the nrfx_twim.h library?&lt;/p&gt;
&lt;p&gt;I ask these questions because for my project, I need to communicate with the module using the nrfx libraries, so I would like to know if I will need to use only nrfx_twim.h or will I need to use both, as in the example.&lt;br /&gt;&lt;br /&gt;Another question, I am using nRF Connect SDK, in this example that I need to use the TWIM driver, do I need to define the pins used in the .overlay file? As in the examples that use I2C communication using the zephyr/drivers/i2c library, in which I define the SDA and SCL pins in the .overlay file.&lt;br /&gt;What parameters do I have to define in the prj.conf file?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using the nrfx_twim.h to develop a simple I2C communicate code</title><link>https://devzone.nordicsemi.com/thread/422268?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 11:34:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25a35883-c68d-46bf-ae82-7a5ee309692d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s several examples using the nrfx driver directly here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/nrfx-2.10.0/nrfx/samples/src/nrfx_twim_twis"&gt;https://github.com/zephyrproject-rtos/hal_nordic/tree/nrfx-2.10.0/nrfx/samples/src/nrfx_twim_twis&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>