<?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>Change Function during Runtime</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45658/change-function-during-runtime</link><description>Hi, I&amp;#39;m new here and I use nRF52832 (pca10040), I was wondering if it is possible to change a function in C / C ++ language during the runtime, that is, my idea is whenever I have a new function, I delete the old one and send via RTT or bluetooth, and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Apr 2019 14:06:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45658/change-function-during-runtime" /><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179798?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 14:06:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c841b0f7-35c0-4131-8707-14262f289c1f</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;As already stated you can&amp;#39;t change the nRF code without performing a firmware update of some sort. This would involve you downloading new firmware for the entire chip or directly writing compiled code into program memory which isn&amp;#39;t a prospect that I would look forward to as you risk bricking your device if it goes wrong.&lt;/p&gt;
&lt;p&gt;You can change the nRF code &lt;strong&gt;behaviour&lt;/strong&gt; if it has been written to use configurable values instead of hard coded ones.&lt;/p&gt;
&lt;p&gt;For example you may wish to change the sampling frequency or scaling of the sensor value. These values could be saved into flash and read back from flash either on start-up or at any point during normal running.&lt;/p&gt;
&lt;p&gt;If you are wanting to perform complex logic on the sensor readings such as statistical analysis then I would suggest that this is performed away from the Nordic device and on your computer.&lt;/p&gt;
&lt;p&gt;In either case it is best to transfer the data from the nRF52 in binary form, without conversion to any other format e.g. text string, HTML or XML, instead perform this either within your phone app or back end computer (which I would recommend).&lt;/p&gt;
&lt;p&gt;It is normally best to ensure that your devices are agnostic to each others domain, so your nRF52 captures the data, the phone app acquires it from the nRF52 and passes it to the computer (over wifi or GSM) and the computer manipulates the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179787?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 13:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:304e0bec-6e21-443a-b535-083717742aba</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;It still doesn&amp;#39;t make sense to me.&lt;/p&gt;
&lt;p&gt;The sensors must be fixed - so the nature of the data they send must also be fixed.&lt;/p&gt;
&lt;p&gt;So the nRF&amp;nbsp; just needs to read the sensors, and pass on those readings.&lt;/p&gt;
&lt;p&gt;So why can the nRF&amp;nbsp;not simply read the sensors, and pass on the data?&lt;/p&gt;
&lt;p&gt;Why does anything ever need to change &lt;em&gt;in the nRF&lt;/em&gt; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179777?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 13:09:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8b90946-f1f5-4609-b9b4-3066523873e8</guid><dc:creator>Nelson.martins</dc:creator><description>&lt;p&gt;The function can be completely changed, it will depend on what is indicated. The ultimate goal is for Nordic to send data to the smartphone (bluetooth) and then to a database (wifi). Whenever the function is changed, Nordic stops reading the sensor when updating the function.&lt;br /&gt;The function has to run in the Nordic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179747?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 11:58:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9529595f-0f34-45b0-bad6-184aa2337a87</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Sounds like it would be better to just send the &lt;em&gt;data&lt;/em&gt;, and let the computer do the appropriate &lt;em&gt;processing&lt;/em&gt; - where it is far easier to change things.&lt;/p&gt;
&lt;p&gt;How, exactly, will the function change?&lt;/p&gt;
&lt;p&gt;Again, a more usual approach would just be to adjust the &lt;em&gt;configuration&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;None of this is specific to Nordic or the nRF52 - it would be just the same on any other Cortex-M4 or comparable embedded &lt;em&gt;microcontroller&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179730?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 11:24:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6108402-e682-4698-ba4e-21a2313a4984</guid><dc:creator>Nelson.martins</dc:creator><description>&lt;p&gt;Sorry for writing in the code editor, I did not realize.&lt;/p&gt;
&lt;p&gt;I have some experience, but I should not have explained it well.&lt;br /&gt;I have a code in the NRF52 to read a sensor and its data to go through the function to send the results. But this function will be constantly changing on the computer depending on the goals. That&amp;#39;s why I wanted to know what I can do, on the nRF52, for whenever I change the function on the computer, the nRF52 realizes this change and updates its function in real time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Change Function during Runtime</title><link>https://devzone.nordicsemi.com/thread/179685?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2019 09:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6ffd580-73ad-49f9-8dfb-ff26b37db392</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Why did you post using the code editor? Keep that just for posting source code!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure what you mean:&lt;/p&gt;
[quote userid="78619" url="~/f/nordic-q-a/45658/change-function-during-runtime"]change a function in C / C ++ language during the runtime[/quote]
&lt;p&gt;Do you have any experience in developing for embedded microcontrollers?&lt;/p&gt;
&lt;p&gt;The normal process is that you build your code to a hex file, and that is programmed into the chips &amp;quot;Read-Only&amp;quot; memory (Flash).&lt;/p&gt;
&lt;p&gt;So you can&amp;#39;t just &amp;quot;change a function&amp;quot; at run time.&lt;/p&gt;
&lt;p&gt;More commonly, you would write a function which can be &lt;em&gt;configured&lt;/em&gt; at run time.&lt;/p&gt;
&lt;p&gt;Scripting languages are available for&amp;nbsp;&lt;span&gt;embedded microcontrollers.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It is, of course, possible to do firmware &lt;em&gt;updates&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Perhaps you could explain what it is that you&amp;#39;re actually trying to achieve here?&lt;/p&gt;
&lt;p&gt;Focus on the &lt;em&gt;goal&lt;/em&gt;, rather than the step:&amp;nbsp;&lt;a href="http://www.catb.org/esr/faqs/smart-questions.html#goal"&gt;http://www.catb.org/esr/faqs/smart-questions.html#goal&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>