<?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>TWI hard faulting</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96690/twi-hard-faulting</link><description>Been working to get the TWI communicating to a LIS331HH and been having tons of trouble getting it functioning. 
 
 I do an init like the example 
 
 
 then when i try to do any tx/rx 
 
 
 following the code by stepping in it goes to this function and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Mar 2023 13:13:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96690/twi-hard-faulting" /><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/413262?ContentTypeID=1</link><pubDate>Fri, 03 Mar 2023 13:13:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c2ca79a-8f17-4a5b-b812-a0dca80a7ae4</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="kclamb2015@gmail.com"]&lt;p&gt;cool example. love the concept but it seems to be just incrementing and counting from 1 to 127. seems to be a similar problem to this guy;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/95520/twi-scanner-showing-random-address"&gt;twi scanner showing random address&lt;/a&gt;&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;Not sure why that would happen. Have you checked the TWI pins with a logic analyzer? Is one of the pins tied to GND/VDD?&lt;/p&gt;
[quote user="kclamb2015@gmail.com"]I&amp;#39;m wondering if it&amp;#39;s because we only have 10k pullups..? Is there a way to enable the internal pullups on the sda/scl lines to help this out?[/quote]
&lt;p&gt;The internal pull resistors should be enabled by default by the TWI driver. You should normally not need to add external pull resistors.&lt;/p&gt;
[quote user="kclamb2015@gmail.com"]Also when we start implementing this into our design, is it in your opinion better to just use the twi manager?[/quote]
&lt;p&gt;That depends on your application, and what you will be interfacing. TWI manager is a higher-level library on top of the TWI drivers to easily allow you to change the configuration of the TWI peripheral between transfers, or to schedule more transfers to different devices. If your TWI slaves all support the same configuration, the driver will normally work fine as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/413124?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2023 20:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f915adba-7e5e-4db9-8cc9-59755f4e7798</guid><dc:creator>kclamb2015@gmail.com</dc:creator><description>&lt;p&gt;cool example. love the concept but it seems to be just incrementing and counting from 1 to 127. seems to be a similar problem to this guy;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/95520/twi-scanner-showing-random-address"&gt;twi scanner showing random address&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m wondering if it&amp;#39;s because we only have 10k pullups..? Is there a way to enable the internal pullups on the sda/scl lines to help this out?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also when we start implementing this into our design, is it in your opinion better to just use the twi manager?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;btw thanks again for all the help, really appreciate it&amp;nbsp;J&amp;oslash;rgen!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/412994?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2023 12:01:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32308c78-6965-4e32-9a4e-42a290de375b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should use the 7-bit address, see that the&amp;nbsp;&lt;a title="ADDRESS" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/twim.html?cp=5_0_0_5_30_6_29#register.ADDRESS"&gt;ADDRESS&lt;/a&gt;&amp;nbsp;register for TWIM is only 7 bits.&lt;/p&gt;
&lt;p&gt;If there is no slave on the bus responding to the address, you should receive an address NACK error.&lt;/p&gt;
&lt;p&gt;Note that you can also use the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/twi_scanner_example.html"&gt;TWI_scanner example&lt;/a&gt; to detect the address of connected slave devices.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/412856?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 23:28:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1aa80871-1f92-4dc5-91dd-e3fac7c56de5</guid><dc:creator>kclamb2015@gmail.com</dc:creator><description>&lt;p&gt;Thanks,&amp;nbsp;I&amp;nbsp;think that&amp;nbsp;and some cleanup did the trick. I&amp;#39;m getting some data back but it looks bogus.&lt;/p&gt;
&lt;p&gt;Should I be using the 7-bit slave address 0x18 or the 8 bit address 0x30?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/411460?ContentTypeID=1</link><pubDate>Wed, 22 Feb 2023 16:26:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6a7ddb7-3828-459f-b03c-1fd19f156243</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The hardfault seems to be caused by modifications in the file &amp;quot;salt_lick_firmware\modules\nrfx\mdk\nrf52810_peripherals.h&amp;quot;. Reverting this file back to the original from nRF5 SDK v17.1.0 seems to fix the issue.&lt;/p&gt;
&lt;p&gt;Setting&amp;nbsp;TWIM_COUNT to 0 will create an empty array of m_handlers in nrf_drv_twi.c, which makes the TWI interrupt handler trying to call an invalid address. The MDK files should&amp;nbsp;normally not be modified, as this can cause issues like this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/410448?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 16:27:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:405d54ae-d86a-4122-bf2b-3d2a8ef09722</guid><dc:creator>kclamb2015@gmail.com</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/salt_5F00_lick_5F00_firmware.zip"&gt;devzone.nordicsemi.com/.../salt_5F00_lick_5F00_firmware.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The code *hopefully* initializes it in twi_init() is called in main. I didn&amp;#39;t know that static variables shouldn&amp;#39;t be accessed by multiple files. there&amp;#39;s probably other things being done wrong here, so we appreciate you looking at it!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/410242?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 08:25:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e038870-64fb-4a95-8966-bc18b72ccd5d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="kclamb2015@gmail.com"]2) we&amp;#39;ve tried several methods, i&amp;#39;m currently down to a simple example to try to get something working and hoping to built from there-this is currently called in main after&amp;nbsp;are setup;[/quote]
&lt;p&gt;It looks to me like you in this example are calling nrf_drv_twi_rx, without first initializing the TWI driver, is that correct?&lt;/p&gt;
&lt;p&gt;Since you have declared m_twi as static in a header file, you should not access it from multiple .c files (e.g. main.c and salt_lick_accel.c), as each file will have its own copy of the object. This means that if you initialize m_twi using a function in&amp;nbsp;&lt;span&gt;salt_lick_accel.c, the m_twi object in main.c will still be uninitialized.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you can upload a .zip file of your project here, that would make it easier for us to reproduce/debug the issue.&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><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/410187?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 21:55:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bc1dc94-b79c-40d1-ba3a-06c275ae4651</guid><dc:creator>kclamb2015@gmail.com</dc:creator><description>&lt;p&gt;Hi J&amp;oslash;rgen, thank you for taking the time to look into this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) it&amp;#39;s defined globally at the top of one of our .h files;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1676497704574v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;which is included at the bottom of our main includes section;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1676497757027v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2) we&amp;#39;ve tried several methods, i&amp;#39;m currently down to a simple example to try to get something working and hoping to built from there-this is currently called in main after&amp;nbsp;are setup;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1676497906025v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;3) S112,&amp;nbsp;i think we originally copied this project from the PCA10040e S112 blinky example&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;4)&amp;nbsp;nRF5_SDK_17.1.0_ddde560&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;we have a git repo if that helps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWI hard faulting</title><link>https://devzone.nordicsemi.com/thread/410009?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 09:24:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50f64c35-ab77-4cc8-8362-79729f74de9c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How is&amp;nbsp;m_twi defined in your application?&lt;/p&gt;
&lt;p&gt;Are you triggering the TX/RX operations from main or interrupt context?&lt;/p&gt;
&lt;p&gt;Do you use a SoftDevice in your application?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which SDK version are you using?&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>