Getting the .hex code file only for a given function

Hello everybody,

I would like to comment some issue I am trying to get. I’m using MPLAB, C30 and a dsPIC30F6015.

Right now I have a main program set at lowest address (between 0x100 and lets say 0x1000). Then I have two different functions allocated at 0x2000 (named lets say F1) and 0x3000 (named lets say F2) respectively. The main loop of the program calls F1 or F2 trhough a function pointer. If I want the main loop to execute F2, I send a serial message and I change the function pointer.

Up to here all is perfect. The think that I want to do is to change the code itself of F1 or F2 through CAN. I have some experience with that: I have got successfully to change all the code of some program in an online way. In order to do that I divide the program space in two parts, so when the dspic is executing one program I can donwload other program in the other part of the program memory.

In order to download the program I read the .hex file generated by MPLAB.

Now I want to donwload only F1 or F2. I could look for the part of theses functions manually in the .hex file and download it, but the question is (at last):

Is there any way to obtain the .hex part file of the function I want to donwload? The point is to avoid looking for (manually or automatically) within the .hex file.

Thanks in advance for your comments and ideas.

Best wishes.