CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Buffers & Memory

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
guest
Guest







Buffers & Memory
PostPosted: Tue May 17, 2005 8:52 am     Reply with quote

Hello all,

I've got an existing program that I've implemented the ring buffer example into on a 16f877 and it works great. I'm reading an 84 character string in the RS232 port and combining it with existing data I'm sending back out the RS232 port. The issue is that it seems 80 is a magic number for the buffer size declaration and I need closer to 90. If I go over 80, the memory usage goes up significantly when I compile and I'm running out of room. Is there an easy way to solve this? Am I going over banks of memory at 80?

thanks much.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 17, 2005 1:21 pm     Reply with quote

Yes there's a limit to the RAM bank sizes. Read the data sheet.

It's possible that you could put your buffer into bank 2 or bank 3,
which have 96 bytes each, without encroaching on the common
ram at the end of each bank. You could use the CCS functions
read_bank() and write_bank() to access this area. This assumes
that you're not using the #device *=16 directive, so that the
compiler won't be using those banks.

See the CCS manual in the read_bank() section. It has a description
of this exact problem, though it's for the older 16c57 series.

I've never done this, so I don't know if the ROM savings is worth
the effort. Most people on this forum will suggest that you upgrade
to the 18F series, which will eliminate the whole problem because
they have much more RAM, ROM, etc.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue May 17, 2005 4:49 pm     Reply with quote

This one is 112 and compiles to 3%ROM 29%RAM which seems about right for the data sheets. Note the largest size is 16+80+16=112.
Code:
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
#include <16F877.h>
#device *=16
#use delay(clock=16000000)
#fuses HS,NOWDT,NOLVP,
#use rs232(baud=19200,xmit=PIN_C4,INVERT,stream=DEBUG) // STDERR(same as DEBUG)
#case
#zero_ram
#RESERVE  0x110:0x17F


int8 buffer[112];//bigest size of block in 16F877 16+80+16=112
#BYTE buffer=0x110
//======================= Main ==============================
void main(void)
{
  int8 i;
  fprintf(DEBUG,"Starting\n\r");
  for (i=0;i<112;i++)
  {
    buffer[i]=i;
    fprintf(DEBUG,"%u\n\r",buffer[i]);
  }
  while(1)
  {
  }
}


Look into the #device *=16 info in the compiler.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group