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%)
Programming warnings & memory usage
Moderator: Benj
-
- Posts: 37
- Joined: Tue May 14, 2013 8:18 pm
- Has thanked: 6 times
- Been thanked: 1 time
- Contact:
Re: Programming warnings & memory usage
Can anyone point me in the right direction, if no-one can answer is there documentation that explains the memory usage.
Ben
Ben
- Steve
- Matrix Staff
- Posts: 3421
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: Programming warnings & memory usage
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.
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.
-
- 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
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
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
-
- Posts: 37
- Joined: Tue May 14, 2013 8:18 pm
- Has thanked: 6 times
- Been thanked: 1 time
- Contact:
Re: Programming warnings & memory usage
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
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
-
- 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
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
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
-
- 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
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.
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
- 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
hmm, Compiler says you have used 61 of 48 bytes. Datasheet says 64
edit: Martin's post beat mine through the ether
and explains the issue
edit: Martin's post beat mine through the ether
and explains the issue