Optimize and save RAM in Flowcode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Genilsonsa
Posts: 150
Joined: Mon Oct 15, 2012 5:19 pm
Has thanked: 12 times
Been thanked: 18 times
Contact:

Optimize and save RAM in Flowcode

Post by Genilsonsa »

Hello friends foristas looks eu again to get a doubt with you.I use here in programming assembly language and C. but when i met this wonderful tool called flowcode spent uses it much more now that economizo here a long time.However realized that flowcode spends a lot more RAM memory and ROM than program made in other compilers.since using several potential registrars that might come there be used .But my curiosity is how i decrease the memória Ram

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Optimize and save RAM in Flowcode

Post by Benj »

Hello,

Flowcode's code generation in terms of RAM and ROM should be pretty much on a par with C. Flowcode generates C and we do our very best to try and ensure things do not eat up too much memory.

Usually the memory is inflated because a component has multiple purposes or ways of working. A lot of the time we use properties to configure a component and this means that the actual compiled code is only taking into account the current property configuration. Sometimes we use a bit more memory because customers need certain features to be configurable on the fly.

Writing code in assembler is always going to be more efficient then C but quickly gets too complicated to do anything complex with. For a short simple program I might choose to use assembler if I'm feeling brave. Saying this if you have a good C compiler then it should be able to get close to the efficiency of assembler without resorting to writing the code instruction by instruction and may often do things in unexpected ways which actually comes out more efficient than readable assembler. The XC compilers provided in Flowcode 7 are the free versions, you can switch to the pro version for 60-days for free to test the difference in code generation capability.

Another way to increase efficiency is to write your own components specific to what you actually need. When writing the code for my propeller clock I wrote about 4 different components each slightly more efficient than the last because I could heavily specialise on what I was doing. e.g. fixed port pins, fixed microcontroller, fixed hardware, fixed array sizes. These things really help to reduce memory usage.


Some good tips for reducing memory usage.

What variables are you using all the time? These should be your global variables. Is there any way to reduce the amount of time you need the variable for.
What variables are you only using temporarily, can these be local variables or maybe you can re-use the variable in another part of the program.
If you have multiple variables which are boolean then these will usually each consume a byte of RAM memory. You can increase the efficiency by manually packing and unpacking multiple bits into a byte or UINT variable.
Use macros where possible to save on ROM space. if you have a section of code you keep repeating in your program then why not create a macro and then simply call the macro multiple times.

Genilsonsa
Posts: 150
Joined: Mon Oct 15, 2012 5:19 pm
Has thanked: 12 times
Been thanked: 18 times
Contact:

Re: Optimize and save RAM in Flowcode

Post by Genilsonsa »

This was a curiosity that I went ,because a program that i did in flowcode precisely emulate Nec protocol with pic 16f628a and accused memoria RAM and ROM full .I transcribed the same program in C and assembly and I realized this difference,but if i put another microcontroller with a greater capacity would work the same way and as I said before FLOWCODE is a great tool that helps me a lot here and i use it.The speed and convenience that it provides us.

Genilsonsa
Posts: 150
Joined: Mon Oct 15, 2012 5:19 pm
Has thanked: 12 times
Been thanked: 18 times
Contact:

Re: Optimize and save RAM in Flowcode

Post by Genilsonsa »

Thank Benj for tips that were very good.I will from now I look for your tip and try to implement in practice.Thank You
:D

Post Reply