Moonwalker 0 Report post Posted October 7, 2015 bool idle = false; unsigned char blinkcnt; char pin[4]; unsigned int t1on, t1off, t2on, t2off; char out1num[11], out2num[11]; char c1stat, c2stat; bool repcall = true, repsms = true; char mysms[80]; char mobnum[15]; //"+35699998888" \0 I am building a project with Sim900 and so involving strings which are Ram consuming. I am using PIC16F1824. Now with the variables as shown above it compiles ok with the following results PS - there are other variables with char arrays elsewhere in the prog. Building... "C:\Program Files (x86)\SourceBoost\boostc_pic16.exe" GsmRemote.c -16x -t PIC16F1824 -idx 1 -obj Debug -d _DEBUG BoostC Optimizing C Compiler Version 7.30 (for PIC16 architecture) http://www.sourceboost.com Copyright© 2004-2015 Pavel Baranov Copyright© 2004-2015 David Hobday Licensed to Julian Muscat under Single user Standard License for 1 node(s) Limitations: PIC12,PIC16 max code size:4096 words, max RAM banks:Unlimited, Non commercial use only GsmRemote.c success "C:\Program Files (x86)\SourceBoost\boostlink_picmicro.exe" -idx 1 /ld "C:\Program Files (x86)\SourceBoost\lib" libc.pic16x.lib Debug\GsmRemote.obj /t PIC16F1824 /d "Debug" /p GsmRemote BoostLink Optimizing Linker Version 7.30 http://www.sourceboost.com Copyright© 2004-2015 Pavel Baranov Copyright© 2004-2015 David Hobday Warning: function never returns: 'error' Building CASM file Memory Usage Report =================== RAM available:256 bytes, used:210 bytes (82.1%), free:46 bytes (17.9%), Heap size:46 bytes, Heap max single alloc:45 bytes ROM available:4096 words, used:3249 words (79.4%), free:847 words (20.6%) So there are 46 bytes free in RAM. But when I change mysms to 90 bytes it does not compile with no RAM available error. bool repcall = true, repsms = true; char mysms[90]; char mobnum[15]; //"+35699998888" \0 Building... "C:\Program Files (x86)\SourceBoost\boostc_pic16.exe" GsmRemote.c -16x -t PIC16F1824 -idx 1 -obj Debug -d _DEBUG BoostC Optimizing C Compiler Version 7.30 (for PIC16 architecture) http://www.sourceboost.com Copyright© 2004-2015 Pavel Baranov Copyright© 2004-2015 David Hobday Licensed to Julian Muscat under Single user Standard License for 1 node(s) Limitations: PIC12,PIC16 max code size:4096 words, max RAM banks:Unlimited, Non commercial use only GsmRemote.c success "C:\Program Files (x86)\SourceBoost\boostlink_picmicro.exe" -idx 1 /ld "C:\Program Files (x86)\SourceBoost\lib" libc.pic16x.lib Debug\GsmRemote.obj /t PIC16F1824 /d "Debug" /p GsmRemote BoostLink Optimizing Linker Version 7.30 http://www.sourceboost.com Copyright© 2004-2015 Pavel Baranov Copyright© 2004-2015 David Hobday Warning unreferenced functions removed: gets in: C:\Program Files (x86)\SourceBoost\include\rs232_driver.h Memory Usage Report =================== Error: No remaining RAM block (on target) big enough for: 'CompTempVar816' size:26 bytes 'CompTempVar851' size:28 bytes RAM available:256 bytes, used:249 bytes (97.3%), free:7 bytes (2.7%), Heap size:0 bytes, Heap max single alloc:0 bytes ROM available:4096 words, used:0 words (0.0%), free:4096 words (100.0%) failure error: failed Failed to locate output file 'Debug\GsmRemote.hex' Done Failed Any help please? Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted October 7, 2015 Changing mysms to 85 bytes I get the following Warning: function never returns: 'error' Building CASM file Memory Usage Report =================== RAM available:256 bytes, used:234 bytes (91.5%), free:22 bytes (8.5%), Heap size:22 bytes, Heap max single alloc:21 bytes ROM available:4096 words, used:3300 words (80.6%), free:796 words (19.4%) success Done How can 5 chars take 24 bytes? Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted November 23, 2015 I have since changed to Pic16F1825 but am still interested to solve the above problem. Quote Share this post Link to post Share on other sites
Reynard 0 Report post Posted November 29, 2015 The linker is having a hard time trying to put all your arrays into the fragmented RAM that the PIC has. I am interested in how you are getting such large temporary variables. 'CompTempVar816' size:26 bytes and 'CompTempVar851' size:28 bytes What are you doing to get temporary variables this size ? Perhaps because of memory allocation difficulties, more temporary variables may be getting used due to all the RAM page switching that has to be done. You need to look at your memory maps to see how RAM is being used and what functions are using more than they should. Moving to the next size PIC is probably the best thing for it. Cheers Reynard Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted November 29, 2015 I am passing strings (char arrays) to functions maybe that is where they are used. With the 16F1825 I have 1024 bytes Ram which solved the problem. Useless to go back to 1824 trying to do magic for a few less cents Quote Share this post Link to post Share on other sites
Reynard 0 Report post Posted November 30, 2015 You are passing strings arrays ! Ouch ! You must have a good reason for not passing a simple pointer to the array then ? Cheers Reynard Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted November 30, 2015 void formattime(int time,char* type) Sorry I am passing pointers as above. My mistake. Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted November 30, 2015 I am using a lot of STRCPY and STRCAT but these also use pointers. Quote Share this post Link to post Share on other sites
Reynard 0 Report post Posted November 30, 2015 Are you copying arrays to arrays when really you don't need to. Are you able to use 'unions' and share RAM. Quote Share this post Link to post Share on other sites
Moonwalker 0 Report post Posted November 30, 2015 Never used unions since they dont look pretty to me. What I have is a char array Mysms and I fill it up with text and numbers using strcpy (first time) and strcat (for the rest). For converting numbers to string I am using uitoa_dec. I am using another array for uitoa_dec and then copying it to mysms array. Maybe I can give uitoa_dec the pointer to the last character of mysms directly? Would that work? Quote Share this post Link to post Share on other sites
Reynard 0 Report post Posted December 1, 2015 Unions are very useful as they allow you to overlay RAM areas that are not in concurrent use. Where you can, format numeric to ascii converted values directly into the output buffer avoiding an intermediate buffer. Put constant text strings into ROM and not hold them in RAM (all your AT commands etc.). When you are short on RAM you will find many tricks to get the best use out of it. Sometimes you can use unused registers to store the odd byte in. Good luck. Quote Share this post Link to post Share on other sites