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 CCS Technical Support

Character String - Out of RAM

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



Joined: 28 Nov 2005
Posts: 17

View user's profile Send private message

Character String - Out of RAM
PostPosted: Mon Nov 28, 2005 11:46 am     Reply with quote

Hi,

I'm trying to store 82 characters in a string, from an RS232 input. When defining my string I get up to a length of 77 chars with 54% RAM usage, but when I try 78 chars I'm told 'Not enough RAM for all variables'. Any ideas? The code below is work in progress and isn't intended to do anyhting yet, I just want to buffer this data first.

Code:

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7)
#endif

#include <lcd.c>

#define  esc            0x1B

void cls();

char letter[1];
char string[78];

#int_RDA
RDA_isr()
{
   letter[0] = getc();
   putc(letter[0]);
   lcd_putc(letter[0]);
}


void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   lcd_init();

   delay_ms(6);
   cls();
   lcd_putc("OK - 3");
   printf("Ready\n\r");
   delay_ms(1000);
   cls();
   printf("Listening\n\r");

   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   while(TRUE)
   {

   }
}

void cls(void)
{
   printf("%c[2J",esc);
}

i want to be able to add letter[0] to a free element in string[82] ideally. I'd appreciate any help with this.

Thanks,

Michael
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 11:49 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=23932
michaelb



Joined: 28 Nov 2005
Posts: 17

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 11:55 am     Reply with quote

oops, sorry. Missed that. Thanks very much for your help,

Michael
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