Macro from external program memory

For general Flowcode discussion that does not belong in the other sections.
Post Reply
christa_0111
Posts: 7
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 11:48 am
Has thanked: 1 time

Macro from external program memory

Post by christa_0111 »

Is it possible to run multiple macros from external memory on an ECIO40P16?
I'm already at 98% program memory utilization and still have a few ideas I'd like to implement!
Thanks for tips and tricks if this is possible!
Christina

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: Macro from external program memory

Post by Steve-Matrix »

I don't believe this is possible in an easy way. A better approach might be to look at optimising your existing project to reduce the code size.

christa_0111
Posts: 7
Joined: Thu Dec 03, 2020 11:48 am
Has thanked: 1 time

Re: Macro from external program memory

Post by christa_0111 »

Code optimization would be easiest with the Microchip compiler, I could save 6-7 percent. I don't want to throw out any of the routines and macros. Basically, for me it's a feasibility study of what's possible!
In any case, thanks for the answer, I'll think about how to proceed!
Christina

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Macro from external program memory

Post by mnfisher »

As Steve says - it's well worth looking if you can refactor your code. There are some fairly simple techniques that can be used to save memory - A couple of simple examples:
replace switch statements with an array lookup table
if you repeatedly print a string followed by a number then create a macro to do this instead of PrintStr, PrintNum.
Use local variables wherever possible instead of global.
Can you post or PM some of your code - and we'll try and suggest some options.

Martin

christa_0111
Posts: 7
Joined: Thu Dec 03, 2020 11:48 am
Has thanked: 1 time

Re: Macro from external program memory

Post by christa_0111 »

Thank you for your effort!
I have already reworked the code into all the options you described. I will simply do some code splitting by outsourcing some functions to an ESP32, since I have integrated WiFi. Using SPI, the MCU ESP32 connection is also fast enough to process some outputs, logging and actual values.
This gives me around 20 to 25 percent free in the MCU, which is definitely enough for me.
Christina

mnfisher
Valued Contributor
Posts: 953
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: Macro from external program memory

Post by mnfisher »

There is a programming axiom "any program can be optimised by at least one instruction" - though taken to its logical conclusion it implies that the best programs have no instructions at all.
I would suspect splitting some code to a second MCU will be quite tricky - why not just use one with more memory?
There are many more optimisation techniques you can apply to squeeze the program size if needed - the offer of taking a look at the code stands, PM it if it is 'sensitive'

Martin

christa_0111
Posts: 7
Joined: Thu Dec 03, 2020 11:48 am
Has thanked: 1 time

Re: Macro from external program memory

Post by christa_0111 »

Oh thank you, you are very honored to be offered to view my code! But that's not my approach! I am self-taught, everything I have achieved I have taught myself. Therefore this code will look like this. It is a code for a 4-fold time relay with 4 times each, including beyond midnight. I packed this code into a pool controller (which is more than is needed here) with the required inputs and outputs for control and sensor data acquisition and it has been running smoothly for several years.
Now I'm sitting here and thinking about what else I can pack in. But at 98 percent capacity, the ceiling is very low. The status and logging functions actually use the most, followed by the control and configuration via WiFi and SMS.
I see an expansion via external memory or code splitting as a new challenge that I'm looking forward to, even if I will run into many dead ends. But that's exactly what's nice when a part works the way I imagine it to. I have enough time since I'm already retired.

So thank you very much for your efforts, of course I'm not attacking the original code (never touch a running system), but I use it as a basis for everything else because I know that it works and I have control over how it works should be!
Christina

Post Reply