I need help with RAM usage please.

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
T3CKN3SS
Posts: 5
Joined: Wed Jun 01, 2016 9:28 am
Has thanked: 5 times
Been thanked: 1 time

I need help with RAM usage please.

Post by T3CKN3SS »

Hello all
Before anyone moans at me, I did see the other topic about this and i did read it and i did try to use the solution given in it but im still using to much RAM. The program isn't very complicated nor is it excessively long.
(I am open to constructive criticism but please go easy on me im still a serious n00b)
I am will attach the .c file (complied by flow code V5)
and i will attach the flow chart file.
Any tips and tricks to help me use less RAM will be greatly appreciated.

The compiler Error:

Memory Usage Report
===================
Error: No remaining RAM block (on target) big enough for:
'CompTempVar2252' size:1 bytes
'CompTempVar2254' size:1 bytes
'CompTempVar2255' size:1 bytes
'$ret' size:2 bytes
'bInterruptsEnabled' size:1 bytes
'del' size:1 bytes

RAM available:64 bytes, used:66 bytes (103.1%), free:-2 bytes (-3.1%),
Heap size:0 bytes, Heap max single alloc:0 bytes
ROM available:1024 words, used:0 words (0.0%), free:1024 words (100.0%)



failure
Return code = -2
Flowcode was unable to assemble the ASM file due to the following errors:



FINISHED

The chip im using : 16f676
Multi Loop pc case mod dual RGB broken.c
This is the .c code.
(31.31 KiB) Downloaded 487 times
Multi Loop pc case mod dual RGB broken.fcf
This is the flow chart .fcf file
(45.44 KiB) Downloaded 456 times
Thank you in advance.
The human brain is nothing more than a simple computer...and Im its hacker.

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times

Re: I need help with RAM usage please.

Post by EtsDriver »

Seems that the RGB led macros are using much RAM... You could try doing RGB led control with PWM, to save on memory. I checked it on FC6, but i think the macro declarations are same on v5.

But seems that even though you could free enough ram, the ROM would be next problem, as your code need's bit more of that. (Try with 16F1823, it has enough ram(double amount), but rom is only a bit bigger than your 676, you will see that rom still goes over couple blocks. (on FC6 ~-200 blocks over.)

SO:

Another solution is to change microcontroller that has more RAM than 64bytes, and has enough ROM, or then you could try to edit the component macro to need less ROM and RAM if you know what you are doing.

Here is side by side comprasion between 16F676 and 16F1824:
pic_comprasion.JPG
(130.6 KiB) Downloaded 2974 times
Here isPIC16F1824 that is supported in FC6, not sure about v5, so please check before ordering.. Same package, Lookin at datasheet it seems to be PIN-TO-PIN compatible... And a bit cheaper than 16F676. Your code will fit to it, and no need to change PCB layout? :)

List:
Found the chip that would fit your application better with Steve's nice Pic list, leave him a thank you if this listing helps, but remeber, its for FC6. :)
http://www.flowcode.co.uk/mmforums/viewt ... ist#p69835

Here are some results trying to compile to hex the project on diffent micros, no changes to your flowchart but using FC6 import.
PIC16F676

Code: Select all


RAM available:64 bytes, used:71 bytes (110.9%), free:-7 bytes (-10.9%), 
Heap size:0 bytes, Heap max single alloc:0 bytes
ROM available:1024 words, used:0 words (0.0%), free:1024 words (100.0%)

failure
PIC16F1823

Code: Select all

Building CASM file
Memory Usage Report
===================
RAM available:128 bytes, used:69 bytes (54.0%), free:59 bytes (46.0%), 
Heap size:59 bytes, Heap max single alloc:31 bytes
ROM available:2048 words, used:2475 words (120.8%), free:-427 words (-20.-8%)
Too much code to fit in ROM, overfilled by:427 locations.

failure
PIC16F1824

Code: Select all

Building CASM file
Memory Usage Report
===================
RAM available:256 bytes, used:69 bytes (27.0%), free:187 bytes (73.0%), 
Heap size:187 bytes, Heap max single alloc:95 bytes
ROM available:4096 words, used:2482 words (60.6%), free:1614 words (39.4%)

success
Ill just keep the good work up!

T3CKN3SS
Posts: 5
Joined: Wed Jun 01, 2016 9:28 am
Has thanked: 5 times
Been thanked: 1 time

Re: I need help with RAM usage please.

Post by T3CKN3SS »

WOW most informative response ever thank you sooo much. il look into the 16F1824 but if ROM is a problem il do some research. The reason i wanted to use the 16F676 is because i happen to have a few here already but hey if it aint gonna do the job then oh well.

Im not sure how to control the RGBs with PWM in FC5 because the RGB in the simulation doesnt seem to respond to the pulses without using the component macros, Il sit and play around with it see if i can get it right.

I cant get FC V6 to run on my laptop but im happy with 5 so il make a plan.
Do you think im being ridiculous in wanting to use more than one chip?
I gave the list a like (thumbs up) il have a longer look at it when i get home.

Thanks so much for the help and the kindness.
:D
Sincerely
T3CKN3SS
The human brain is nothing more than a simple computer...and Im its hacker.

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times

Re: I need help with RAM usage please.

Post by EtsDriver »

Here are some examples of Software PWM, you could try it out:

http://www.flowcode.co.uk/article.php?a=52

And i made a little try/example just now:
Using 16F1937.
Main:
Main.jpg
(49.31 KiB) Downloaded 2928 times
Interrupt:
INTERRUPT1 macro.jpg
INTERRUPT1 macro.jpg (37.61 KiB) Viewed 7295 times
Here is a short video about it:
https://www.youtube.com/watch?v=iTxnWX4wd6U
Ill just keep the good work up!

Steve001
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed Dec 31, 2008 3:37 pm
Has thanked: 460 times
Been thanked: 523 times

Re: I need help with RAM usage please.

Post by Steve001 »

Hi T3CKN3SS

have you seen this post may be of some use it's a V4 version on controlling a tri colour LED With PWM you should be able to open it in V5 :D

http://www.flowcode.co.uk/article.php?a=365

Steve
Success always occurs in private and failure in full view.

Post Reply