Arrays takes up all memory

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

Moderator: Benj

Post Reply
Andreas
Posts: 17
Joined: Tue Jan 17, 2017 6:10 pm
Has thanked: 4 times
Been thanked: 1 time
Contact:

Arrays takes up all memory

Post by Andreas »

Hi

I am working on a program with 3 arrays. Right now all three arrays contain 13 bytes, but i would like to expand all of those. Unfortunately the compiler makes som kind of memory-error, when I try to expand to 14 bytes per array.

I have attacched the .msg.txt file with the error message.

I have tried to make som investigation of the problem, and when I take a look at the memory while I compile with 12 and 13 bytes in each array i see that the difference in memory isn't very big.

With 13-bytes in each array I get the following memory-summary
Memory Summary:
Program space used E2Fh ( 3631) of 1000h words ( 88.6%)
Data space used C4h ( 196) of 170h bytes ( 53.3%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Data stack space used 0h ( 0) of 60h bytes ( 0.0%)
Configuration bits used 2h ( 2) of 2h words (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
With 12-bytes in each array I get the following
Memory Summary:
Program space used E2Fh ( 3631) of 1000h words ( 88.6%)
Data space used C1h ( 193) of 170h bytes ( 52.4%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Data stack space used 0h ( 0) of 60h bytes ( 0.0%)
Configuration bits used 2h ( 2) of 2h words (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
I am using Microchips PIC16F88 as microcontroller.

I would like to hear if there is anything I can do to maybe free up the missing memory og use it in a better way.

I read about that it could have something to do with how the code is distributed into the controllers individual memory-banks.

I have a function in FlowCode which only uses assembly-code, because it drives some time-critical hardware, and I do not want to mess to much around with it. Of some reason FlowCode is pointing to one of the C-blocks with assembly-code in that function as an error result, when the compilation-error occours, as if it is excatly that c-block that is causing the error, which is weird because it does not use any of the arrays.

Thank you in advance

-Andreas
Attachments
Kombination af LED og mic V5.msg.txt
(1.19 KiB) Downloaded 240 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arrays takes up all memory

Post by LeighM »

From what you have given, it looks like it might not be a memory space issue, but something to with your use of the arrays,
it would be useful to have your program to give more help.

Andreas
Posts: 17
Joined: Tue Jan 17, 2017 6:10 pm
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: Arrays takes up all memory

Post by Andreas »

Thank you for the answer

I have attached the program here.

I did some cleanup in the program for your convenience, and it made it possible for me to make room for 14 bytes per array, but no more, and the memory-summary does not seem to have changed much.

The arrays are globals and are called redArray, greenArray and blueArray in FlowCode.

Not all comments are in english, so if any questions occour I am pleased to answer.

-Andreas
Attachments
Kombination af LED og mic V5.fcfx
(41.66 KiB) Downloaded 230 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arrays takes up all memory

Post by LeighM »

Hi,
It looks like the error is due to the fact that when you increase the array sizes the greenArray gets pushed out of bank 1 and into bank 3
That then causes errors with the assembly code in VIS, so you will probably need to add bank selecting code into those.
I'm a bit rusty on that, it's been decades since I last did any PIC asm

Andreas
Posts: 17
Joined: Tue Jan 17, 2017 6:10 pm
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: Arrays takes up all memory

Post by Andreas »

Hi

Thanks

Now I understand why those assembly-blocks were highlighted each time the error occurred

By looking at the auto-generated assembly-code FlowCode creates when reading from one of the arrays (via the regular calculation-block in FlowCode) I have found out how to access the arrays in the correct banks by indirect addressing in assembly. So now i am able to have 48 bytes in each array. redArray and blueArray shares all the memory in bank 3 (96 bytes) and greenArray uses 48 of 96 bytes in bank 2 (the rest of the bank is empty)

So this was a major improvement. Thanks again.

But now i am getting curious (and a bit greedy). The case now is that 50% of bank 2 is empty, and about the same amount in bank 1. Do you know if it is possible to force each of the arrays to be in each of the different banks: Bank 1, Bank 2 and Bank 3? In that way I would be able to increase the size of each array even further provided that some of the data in bank 1 is distributed to all of the banks 1, 2 and 3. This would also give me the control of in which bank each array is.

- Andreas

Post Reply