Jump to content

Recommended Posts

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)
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
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)
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
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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

You are passing strings arrays ! Ouch !

 

You must have a good reason for not passing a simple pointer to the array then ?

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

Are you copying arrays to arrays when really you don't need to.

 

Are you able to use 'unions' and share RAM.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...