<?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>Build generic function with TWI read</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45190/build-generic-function-with-twi-read</link><description>I take the TWI master example of nordic, and try to build I2C read API that can be use from otherr places. 
 The function look like this 
 uint32_t Serial_read_2BytesReg(uint8_t instance,uint8_t dev_add, uint16_t reg_add,void const * p_buffer,size_t size</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Mar 2019 08:01:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45190/build-generic-function-with-twi-read" /><item><title>RE: Build generic function with TWI read</title><link>https://devzone.nordicsemi.com/thread/178004?ContentTypeID=1</link><pubDate>Mon, 25 Mar 2019 08:01:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22f0e447-e6a4-4b31-bfe9-3de20b732817</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;[quote user="BarS"][/quote]&lt;/p&gt;
&lt;p&gt;I use the&amp;nbsp;&lt;span&gt;TWI callback.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I don&amp;#39;t know which SWI it use for the I2C.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ok, then it&amp;#39;s the I2C interrupt.&lt;/p&gt;
[quote user="BarS"]How can I get information from the hardfault handler when it jump there?[/quote]
&lt;p&gt;You should use the hardfault handler from the hardfault handling library. Just add the following files to your build and enable the handler in sdk_config.h:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;- nRF5_SDK_15.3.0_59ac345\components\libraries\hardfault\hardfault_implementation.c&lt;/p&gt;
&lt;p&gt;&amp;nbsp;- nRF5_SDK_15.3.0_59ac345\components\libraries\hardfault\nrf52\handler\hardfault_handler_*.c&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This handler will attempt to determine the cause and print out the error information.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Build generic function with TWI read</title><link>https://devzone.nordicsemi.com/thread/177919?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2019 19:47:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:690da81f-905d-4a40-bbd9-e9295e281985</guid><dc:creator>Bar</dc:creator><description>&lt;p&gt;I use the&amp;nbsp;&lt;span&gt;TWI callback.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I don&amp;#39;t know which SWI it use for the I2C.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How can I get information from the hardfault handler when it jump there?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bar.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Build generic function with TWI read</title><link>https://devzone.nordicsemi.com/thread/177715?ContentTypeID=1</link><pubDate>Fri, 22 Mar 2019 07:12:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8354ad8-5679-4465-82ae-c197acb36cef</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately, it&amp;#39;s hard to say why you get hardfault&amp;nbsp;without debugging your code.&amp;nbsp;&amp;nbsp;It would be helpful if you could try to narrow it down a bit more. Maybe you can try our&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-3-0/lib_hardfault"&gt; hardfault handling library&lt;/a&gt;&amp;nbsp;to find out what triggers it.&amp;nbsp;&lt;/p&gt;
[quote userid="76576" url="~/f/nordic-q-a/45190/build-generic-function-with-twi-read"] see it return 0x00 and the NACK but on my SWI don&amp;#39;t get to the callback and I jump into error&amp;nbsp;on HardFault_Handler.[/quote]
&lt;p&gt;Are you using a SW interrupt (SWI), or are you referring to the TWI callback?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Build generic function with TWI read</title><link>https://devzone.nordicsemi.com/thread/177564?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2019 12:01:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa0bb894-5952-4f65-890b-6d4da590607a</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/02742._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>