This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Change Function during Runtime

Hi, I'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 save the new function in flash memory. I'm thinking of putting the function in a dynamic library to change, but I do not know if it works on nRF52.

Best regards.
  • Why did you post using the code editor? Keep that just for posting source code!

    I'm not sure what you mean:

    change a function in C / C ++ language during the runtime

    Do you have any experience in developing for embedded microcontrollers?

    The normal process is that you build your code to a hex file, and that is programmed into the chips "Read-Only" memory (Flash).

    So you can't just "change a function" at run time.

    More commonly, you would write a function which can be configured at run time.

    Scripting languages are available for embedded microcontrollers.

    It is, of course, possible to do firmware updates.

    Perhaps you could explain what it is that you're actually trying to achieve here?

    Focus on the goal, rather than the step: http://www.catb.org/esr/faqs/smart-questions.html#goal

  • Sorry for writing in the code editor, I did not realize.

    I have some experience, but I should not have explained it well.
    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'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.

  • Sounds like it would be better to just send the data, and let the computer do the appropriate processing - where it is far easier to change things.

    How, exactly, will the function change?

    Again, a more usual approach would just be to adjust the configuration.

    None of this is specific to Nordic or the nRF52 - it would be just the same on any other Cortex-M4 or comparable embedded microcontroller.

  • 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.
    The function has to run in the Nordic.

  • It still doesn't make sense to me.

    The sensors must be fixed - so the nature of the data they send must also be fixed.

    So the nRF  just needs to read the sensors, and pass on those readings.

    So why can the nRF not simply read the sensors, and pass on the data?

    Why does anything ever need to change in the nRF ?

Related