<?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>HardFault error when writing to characteristic in uart interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16666/hardfault-error-when-writing-to-characteristic-in-uart-interrupt</link><description>Hello everyone, 
 When i get message from uart, i need to update my custom service&amp;#39;s characteristic. I tried the code in the below, sd_ble_gatts_value_set function gives me HardFault error. 
 Am I doing something wrong to add characteristic? how should</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Sep 2016 06:28:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16666/hardfault-error-when-writing-to-characteristic-in-uart-interrupt" /><item><title>RE: HardFault error when writing to characteristic in uart interrupt</title><link>https://devzone.nordicsemi.com/thread/63763?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2016 06:28:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f673a5e2-b483-4920-ba69-5c40bcf6c734</guid><dc:creator>Hakan</dc:creator><description>&lt;p&gt;Thank you this way is better :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HardFault error when writing to characteristic in uart interrupt</title><link>https://devzone.nordicsemi.com/thread/63762?ContentTypeID=1</link><pubDate>Tue, 27 Sep 2016 07:21:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c318d3a-6876-4b71-b91f-ab38d70606ff</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sending an SV instruction from an higher interrupt priority context than the SV call (&amp;#39;2&amp;#39;) itself will lead to a hardfault exception. Setting the interrupt priority to &amp;#39;APP LOW&amp;#39; in the initialization of the UART should fix this problem. Calling the sd_ble_gatts_value_set() function in main context as you described will also work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HardFault error when writing to characteristic in uart interrupt</title><link>https://devzone.nordicsemi.com/thread/63761?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 15:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66bfc94b-1400-400c-8682-3e373c13d378</guid><dc:creator>Hakan</dc:creator><description>&lt;p&gt;I found the solution but i want to know if there is more proper way.&lt;/p&gt;
&lt;p&gt;If i receive the right message from uart, i set a variable to 1. Then i am checking for that variable is set on for loop in main function. If set, i am writing to characteristic via sd_ble_gatts_value_set&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>