<?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>nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23177/nrf52840-twim</link><description>First try to create a TWIM driver from scratch without any DMA. Following the steps in the OPS I get mixed behavior and only the chapter with DMA generates any clock and data on the interface. Without setting Master enable bit nothing will start and there</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Aug 2017 09:29:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23177/nrf52840-twim" /><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91167?ContentTypeID=1</link><pubDate>Mon, 14 Aug 2017 09:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:022b9b32-ccd3-40f2-a9b1-63bacf48736f</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;No need for any trace when the signal are low.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91169?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2017 14:50:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c73c16f3-c552-4b3b-8df4-3729ea27f78d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Regarding GPIO configs I haven&amp;#39;t changed anything.&lt;/p&gt;
&lt;p&gt;Are you able to upload a logic trace?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91168?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2017 09:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b1d601b-2d71-4f3f-88ef-45c35ef6b0fc</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;Sill waiting for answers. One note in your picture where you send 0xAA but is not in your code. It could be the random data from RAM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91165?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 11:51:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1ad6566-7599-42b2-81a7-8e0df37a19f4</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;EDIT: Yes I know about the differences between TWI and TWIM.&lt;/p&gt;
&lt;p&gt;Because the TWI do not describe any STOP and START conditions that are vital for I2C I then borrowed that was closes to the part I needed from TWIM. This is a guess because chapter 48 do not describe anything about this. Even if I use TWIM with DMA it should work but it does not, How about your GPIO_PIN_CONF?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91173?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 10:54:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c39f4cad-f75c-4369-a7a9-0f7e1e8cc718</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I have added another edit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91174?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2017 07:30:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a79c62a-e361-426e-8eb0-904c34ec2d73</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;No luck with the drive strength changes and TXD works so I think this part is Ok. So I&amp;#39;m stuck right now but I have two questions to you. And basically because your example is DMA for sure and my thread is about non-DMA.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Have you setup anything prior to this e.g. DMA configuration?&lt;/li&gt;
&lt;li&gt;What have you set on the GPIO configuration (PIN_CONF) for your I2C pins?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91172?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2017 15:59:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b59b9c5-2da0-4272-9d3f-9ee3fa27987d</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;Yes I did test the setup with a I2C-USB cable connected to the SDOF stick, so I know that I have the right device address. I have not setup any Nordic environment so I cannot test your test code.&lt;/p&gt;
&lt;p&gt;In my case with your code converted to my source I do not get anything more then low pins.&lt;/p&gt;
&lt;p&gt;I will try to change the drive strength but in my first code example TXD worked!?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91175?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2017 13:36:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cba9327b-be2e-4f1a-95b7-f959ce2473b7</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Please see the edit in my previous answer. Also, have you tried the twi_scanner example in the SDK? It is useful for making sure that everything is wired correctly and working properly. It will also show you what address to use in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91171?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2017 13:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdea3ec2-59a0-4d87-9aeb-76af4334a87c</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;It did not work. The interface pins goes low when master mode is enabled and that’s it, nothing more.&lt;/p&gt;
&lt;p&gt;Just to make sure I did it right I give you the change below including the defines.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// register map
#define I2C_STARTRX_REG		0x0000
#define I2C_STARTTX_REG		0x0008
#define I2C_STOP_REG		0x0014
#define I2C_SUSPEND_REG		0x001C
#define I2C_RESUME_REG		0x0020
#define I2C_STOPPED_REG		0x0104
#define I2C_RXDREADY_REG	0x0108
#define I2C_TXSENT_REG		0x010C
#define I2C_ERROR_REG		0x0124
#define I2C_BB_REG			0x0138
#define I2C_SUSPENDED_REG	0x0148
#define I2C_RXSTARTED_REG	0x014C
#define I2C_TXSTARTED_REG	0x0150
#define I2C_LASTRX_REG		0x015C
#define I2C_LASTTX_REG		0x0160
#define I2C_SHORT_REG		0x0200
#define I2C_INTENSET_REG	0x0304
#define I2C_INTENCLR_REG	0x0308
#define I2C_ERRORSRC_REG	0x04C4
#define I2C_ENABLE_REG		0x0500
#define I2C_PSEL_SCL_REG	0x0508
#define I2C_PSEL_SDA_REG	0x050C
#define I2C_RXD_REG		0x0518
#define I2C_TXD_REG		0x051C
#define I2C_FREQUENCY_REG	0x0524
#define I2C_RXD_PTR_REG		0x0534
#define I2C_RXD_MAXCNT_REG	0x0538
#define I2C_RXD_AMOUNT_REG	0x053C
#define I2C_RXD_LIST_REG	0x0540
#define I2C_TXD_PTR_REG		0x0544
#define I2C_TXD_MAXCNT_REG	0x0548
#define I2C_TXD_AMOUNT_REG	0x054C
#define I2C_TXD_LIST_REG	0x0550
#define I2C_ADDRESS_REG		0x0588

output_32( USED_I2C_BLOCK+I2C_ENABLE_REG, 0 );

output_32( USED_I2C_BLOCK+I2C_SHORT_REG, (1&amp;lt;&amp;lt;12) | (1&amp;lt;&amp;lt;9) );

output_32( USED_I2C_BLOCK+I2C_ADDRESS_REG, (SlaveAddress&amp;lt;&amp;lt;1) );

output_32( USED_I2C_BLOCK+I2C_TXD_PTR_REG, 0x20021000 );
output_32( USED_I2C_BLOCK+I2C_TXD_MAXCNT_REG, 1 );

output_32( USED_I2C_BLOCK+I2C_RXD_PTR_REG, 0x20020000 );
output_32( USED_I2C_BLOCK+I2C_RXD_MAXCNT_REG, DataBufferSize );

output_32( USED_I2C_BLOCK+I2C_ENABLE_REG, 1 );

output_32( USED_I2C_BLOCK+I2C_LASTTX_REG, 1 );

output_32( USED_I2C_BLOCK+I2C_STARTTX_REG, 1 );

// Wait for TX to complete
TIMER_Timer_Delay( 100000 );

output_32( USED_I2C_BLOCK+I2C_STARTRX_REG, 1 );
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91170?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2017 12:21:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d12ce05-8fc8-45d5-a288-6659f9d418d7</guid><dc:creator>jlz</dc:creator><description>&lt;p&gt;Yes the output/input works (used for 20 years, no change ;)&lt;/p&gt;
&lt;p&gt;I’m not using DMA and I guess that you do not need to set the pointer to TX/RX and directly read from the TXD/RXD. Also the chapter without DMA do not describe this part.&lt;/p&gt;
&lt;p&gt;No the controller do not add the READ bit so I have to add it. I shift the slave address because it’s an 7-bit address.&lt;/p&gt;
&lt;p&gt;I will try your approach because it’s more simple then my more complex implementation. If everything are handle in hardware I do not have to do it manually that I’m currently doing now.&lt;/p&gt;
&lt;p&gt;If you need more info or missing defines I can add them to the thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 TWIM</title><link>https://devzone.nordicsemi.com/thread/91166?ContentTypeID=1</link><pubDate>Tue, 04 Jul 2017 10:39:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be96e8db-5c44-464b-bfc2-3b06fcd83e61</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Assuming that your output_32() function is bug free;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Are you sure it is necessary to left shift the slave address?&lt;/li&gt;
&lt;li&gt;Do you really need to add 1 to the address when reading from a slave? The TWI module takes care of that.&lt;/li&gt;
&lt;li&gt;Where do you set the TX and RX buffer?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here is one way to use do a &amp;quot;bare bone&amp;quot; TX/RX transfer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void twi_transfer()
{
    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos;
    NRF_TWIM0-&amp;gt;SHORTS = (TWIM_SHORTS_LASTTX_STOP_Enabled &amp;lt;&amp;lt; TWIM_SHORTS_LASTTX_STOP_Pos) | 
                        (TWIM_SHORTS_LASTRX_STOP_Enabled &amp;lt;&amp;lt; TWIM_SHORTS_LASTRX_STOP_Pos);
    
    
    NRF_TWIM0-&amp;gt;PSEL.SCL = MPU_TWI_SCL_PIN;
    NRF_TWIM0-&amp;gt;PSEL.SDA = MPU_TWI_SDA_PIN;
    NRF_TWIM0-&amp;gt;FREQUENCY = TWI_FREQUENCY_FREQUENCY_K400;
    NRF_TWIM0-&amp;gt;ADDRESS = MPU_ADDRESS;
    
    NRF_TWIM0-&amp;gt;TXD.PTR = (uint32_t)&amp;amp;p_tx_buffer;
    NRF_TWIM0-&amp;gt;TXD.MAXCNT = 1;
    
    NRF_TWIM0-&amp;gt;RXD.PTR = (uint32_t)&amp;amp;p_rx_buffer;
    NRF_TWIM0-&amp;gt;RXD.MAXCNT = 1;
    
    NRF_TWIM0-&amp;gt;ENABLE = TWIM_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; TWIM_ENABLE_ENABLE_Pos;
    
    NRF_TWIM0-&amp;gt;EVENTS_LASTTX = 0;
    NRF_TWIM0-&amp;gt;TASKS_STARTTX = 1;
    
    // Wait for TX to complete
    nrf_delay_us(100);
    
    NRF_TWIM0-&amp;gt;TASKS_STARTRX = 1;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TWIM0-&amp;gt;SHORTS = (TWIM_SHORTS_LASTTX_STARTRX_Enabled &amp;lt;&amp;lt; TWIM_SHORTS_LASTTX_STARTRX_Pos)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To start an RX immediately after the TX is completed.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what is going on inside output_32(), but you seem to know how to use register base addresses and register offsets, so I think the above code should be easy for you to port.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;
The above code will produce the following action on the TWI bus:
&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/logic-trace.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;You can see that the TWI module takes care of left shifting of your 7-bit address and adds the READ bit automatically.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT 2:&lt;/strong&gt;
I have reviewed the case again and noticed a few more things that I didn&amp;#39;t see initially:&lt;/p&gt;
&lt;p&gt;Since you talk about DMA and use the I2C_TXD_MAXCNT_REG register, but at the same time also talk about using TRD/TXD registers directly it sounds like you are cherry picking features from the legacy TWI module and the new TWIM module.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The legacy TWI module is basically &amp;quot;copy-pasted&amp;quot; hardware from the nRF51. It has a lot less features than the new module in nRF52. It does not have any DMA features for example. If you want to use the legacy module and use TXD/RXD registers directly you can only use the features available in this particular module. &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/twi.html?cp=2_1_0_48#concept_rhy_rzp_sr"&gt;Legacy TWI documentation&lt;/a&gt;. With the legacy module you will have to update the TXD register for every byte you want to send.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The new module in nRF52 is an extension of the legacy module and hence shares some of the same registers. If you want to use DMA you will have to use the features documented &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/twim.html?cp=2_1_0_32#concept_scx_f5p_xr"&gt;here&lt;/a&gt; and you cannot use RXD/TXD directly.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>