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

Questions on calling external function

Excuse me, I have a question on calling external function. 

board using: nrf52832

softdevice using : s132(6.1.1)

The situation: There are two applications  which is named as app1.c and app2.c . In app1.c, there is the main application which will handle all the work . In app2.c will only contain a function which will return a value. For example, app2.c contain the function int foo(char a1, char b2). In my project, may I program these two application separately in two memory address in which app1.c can call the function in app2.c externally. 

for example in app1.c:

int main(){

int a = foo('a','b');//call the function in app2.c and use the value returned later

}

Reason to do this: These two application is written by two different person so that one can call the external function when it is needed. 

Searching the internet, I find that superior call interface will be helpful but I cannot understand how it works after reading the document: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.1.0%2Flib_svc.html&anchor=lib_svc_reserved_svc_number

May you give me an example on how to use the superior call interface to call an external function which is located at a specific address.The document is quite difficult to follow as it has several section and has not provided a deep explanation 

Question list:

a) do I need to program the bootloader into the board before using the svc.

b) can the svc works when the external function store at another memory address. e.g. app1 stores at 0x46000 having a size of 0x20000, external function saving at 0x66000

c) may you give me an example on how to use the superior call interface to call an external function which is located at a specific address

d) if svc does not work may you suggest me a better alternatives on programming two application on the same block of memory  and enabling jumping between

All in all, thank you for your attention and I will appreciate and be grateful for any help from others.

Parents Reply Children
  • Hi,

    I also thought it was the other way around at first, but then I read the posts more carefully and it looks like the other people is making the application. Some clarification from would be good here.

    Regards,
    Terje

  • Thank you for all your help. Library definitely is one of the key to the problem.  Refer to tesc, other people  making the application is true provided that I am responsible for writting a function for him to call only. The plan is that he will provide me the hex file of the application and I need to link his hex file with my hex file which contains the code of my function written. Searching the internet, it seems that function cannot be independently exists in a hex file given that I am using Keil as the ide. Therefore, may I ask whether I can store my function at another block of memory and link it to the application hex file. Although library is one the key but it will be inconvenient to implent as I have to give the writter couple of files when amendment is required. Again, I am grateful for all the help from you guys :)

  • Sorry what's all this 'hex file' rubbish. Hex files are generated as the final step of making a complete application, they are just the bits which get dumped on the chip at the end. Trying to do this by having different hex files loaded at explicit memory addresses which functions with fixed addresses is going to be a nightmare to try and sort out even if you were brilliant with Keil and frankly the way you mix up terms in your mail doesn't give me the feeling you are. 

    Making a library, which Keil is completely capable of doing, is what you want to do here. You compile the one function you are writing into a library and you send him 

    1) the library

    2) a header file

    then he adds the library to his keil project and includes the header file and builds the application. That's it. 

    If you change the function you send him a new library, a process which should take you about 10 seconds. 

  • a library, which Keil is completely capable of doing, is what you want to do here

    Absolutely!

    Although library is one the key but it will be inconvenient to implent

    Go on!

    It is the standard, tried & tested way of doing it!

    It is an order of magnitude less "inconvenient" than all the messing about with hexfiles you suggest!!

    Seriously: Just Use A Library!

    This is exactly what libraries are for.

  • Thank you all for being helpful. I would try using library and see what the result is. I truely thank you for all your help.

Related