Programming warnings & memory usage

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

Moderator: Benj

Post Reply
beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Programming warnings & memory usage

Post by beneee »

I have been working on a program for a 12F1501 and as the project gets bigger so does the program and data space that it uses - this is expected, I am surprised about how quickly they go up though with very little in the project so I am assuming the chip I am using has very little space.

One curiosity is the data space hit 100% and worked then continued to grow and my project is now almost complete and it is now 127.1% and still writing to the chip without issue and working, what is happening here?

I also have 4 warnings which I am assuming are related to the 4 PWMs I am using but unsure how to fix this.

The snip of the compiler message is below and I have attached my program in case you want to look though it and be appalled at the inefficient code - please feel free to edit and optimise.

Thanks
Ben

* From the data sheet, the 12F1501 has 1024 program memory flash words and 64 bytes of data SRAM *

. . . . .

using updated 32-bit floating-point libraries; improved accuracy might increase code size
Small.c: 785: (1257) local variable "_FCR_RETVAL" is used but never given a value (warning)
Small.c: 963: (1257) local variable "_FCR_RETVAL" is used but never given a value (warning)
Small.c: 1141: (1257) local variable "_FCR_RETVAL" is used but never given a value (warning)
Small.c: 1319: (1257) local variable "_FCR_RETVAL" is used but never given a value (warning)
. . .


Memory Summary:
Program space used 304h ( 772) of 400h words ( 75.4%)
Data space used 3Dh ( 61) of 30h bytes (127.1%)
EEPROM space None available
Data stack space used 0h ( 0) of 1h byte ( 0.0%)
Configuration bits used 2h ( 2) of 2h words (100.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
Small.fcfx
(23.09 KiB) Downloaded 152 times

beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: Programming warnings & memory usage

Post by beneee »

Can anyone point me in the right direction, if no-one can answer is there documentation that explains the memory usage.

Ben

User avatar
Steve
Matrix Staff
Posts: 3422
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Programming warnings & memory usage

Post by Steve »

These are messages from the XC8 compiler. It seems strange that it's working though, as I would have assumed it would fail if too much memory is being used. It might be best to get this value below 100% as it could cause unexpected problems within your program (e.g. variables being overwritten).

Data space is essentially the RAM of the device and is where variables are allocated. If more than 100% of the space is being used, it could show this memory is being recycled for other variables. You could try being more careful about the data types you use (use bytes where you can), reducing the array/string sizes, and perhaps reuse the same global variables. You could also try using local variables instead of global variables as that might make things more efficient.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Programming warnings & memory usage

Post by stefan.erni »

Hi Ben

This PIC has very little ram maybe you can switch to one with 256 byte
Here a link to the 8pin 8bit PIC.

https://www.microchip.com/ParamChartSea ... nchID=1001

regards
stefan
PIC8.png
PIC8.png (112.69 KiB) Viewed 3250 times

beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: Programming warnings & memory usage

Post by beneee »

Thanks.

I only picked that one as it had 4 PWM outputs in a 8 pin package so my choices were a bit limited.

Still curious as to why I can use 127% of the available data space.

Ben

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Programming warnings & memory usage

Post by stefan.erni »

Hi Ben

Half of the people cannot calculate percentages, that are more than 80%.

I suspect the calculation is wrong.
But you don't have much ram left, with one or two 16Bit more is the limit. A byte need 1Ramplace an integer need 2Ramplace.
Is a 16Pin PIC an option?

regards

Stefan

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Programming warnings & memory usage

Post by medelec35 »

Hi guys,
I know the XC8 compiler shipped with Flowcode has a bug that reports wrong memory values.
When I went to XC8 versions of 2.00 and greater, bug was no longer present.
Martin

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: Programming warnings & memory usage

Post by LeighM »

hmm, Compiler says you have used 61 of 48 bytes. Datasheet says 64

edit: Martin's post beat mine through the ether :lol:
and explains the issue

Post Reply