Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:17 30 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CHAIN vs one big program....

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9065
Posted: 02:26pm 04 Nov 2013
Copy link to clipboard 
Print this post

I am looking at breaking up my now quite large code into smaller bits, each one called from the main menu using the CHAIN command.

Is there any advantage to this, or is it a case of: If it all fits in the memory as one big program, leave it that way. Chain is more for really huge code, which simply won't fit in the memory all at once.

I figured that separate modules of code, perhaps might be easier to debug and manage etc.
...that might be false logic.

Any comments welcomed.
Smoke makes things work. When the smoke gets out, it stops!
 
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 11:42pm 05 Nov 2013
Copy link to clipboard 
Print this post

Any time the chain command is used, the memory card is accessed. I have been led to believe that SD cards will eventually wear out with many read/writes so it may be a deciding factor. I think chaining is mainly a tidy way of modularising. If it has other advantages I will no doubt learn from other people's answers.

David
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 02:55am 06 Nov 2013
Copy link to clipboard 
Print this post

CHAIN and LIBRARY are both good ways to split programs into logical block.
Best to load often used routines with LIBRARY and the use CHAIN for loading specific tasks that have to be performed.
Every chained program still can use the routines loaded with library so it can speed up loading time and also saves on memory use.
Both these command will read a file from the drive. This is no problem as reading an SD card or internal flash does not wear it out.
Only writing operations will do that.

Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9065
Posted: 01:02pm 06 Nov 2013
Copy link to clipboard 
Print this post

Thanks for the replies. I will study this option a bit more. My program is working fine as one huge code in Mode 4, but I find that I am running into issues when I need to display the activity log on the screen(read from a file on the SD card), in that switching back to Mode 3 causes the program to stop with an error code - not enough memory. I am getting around that at the moment by using Mode 2,1 instead, and just not having as many colours - probably not necessary for reviewing a log file anyway - lots of colour, I mean. I could probably even go to Mode 1,2 for example, and just have the log screens in one colour only.

I will have a little think.

EDIT: ...or I could have the log-viewer code as a seperate program and CHAIN to that one, then back to the main code. That would allow me to use full Mode 3 and all colours for nice pretty log readouts...

It's nice to have options. Edited by Grogster 2013-11-07
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024