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

Problem with RAM

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



Joined: 29 Sep 2009
Posts: 6

View user's profile Send private message

Problem with RAM
PostPosted: Thu Oct 29, 2009 2:51 am     Reply with quote

Hi everybody!

I have a problem with my RAM, Not enough RAM for all variables.

But it is in a very strange way.

First a bit of information:

PIC 16F887
Compiler CCS 4.006 with mplab

The thing is that I have a function:
Code:

void send_msg (long int c)
{                   

//int basura[32];

int mensaje[38]={tw1,tw0,tw0,tw0, tw0,tw0,tw0,tw0, tw0,tw0,tw0,tw1,
             tw0,tw0,tw0,tw0, tw1,tw0, tw0,tw0,tw0,tw0,tw0,tw0,tw0,tw0
             tw0,tw1,tw1,tw1, tw1,tw1,tw1,tw1, tw1,tw1,tw1,tw0};

int i=0;

bit_set(c,9);
bit_clear(c,8);

// primero calculo los tiempos de los bits configurables
for (i=12; i<26; i++)
   {
   if (bit_test(c,25-i)==1) {mensaje[i]=tw1;};
   }

for (i=0; i<38; i++)
   {
   DIGIN=1; delay_us(mensaje[i]); DIGIN=0; delay_us(tws);
   }

}

That produces this error, but if I put a new array (basura) with a number of elements between 3 and 32 the occuped RAM goes from 96% for 3 to 85% for 32.

I believe that this decrement in used RAM is because the compiler scratch some local variables that it declares as global since there is no need to be local when I do not declare the 32 elements array.

For me the very strange thing is that I need this array to work, does anybody know why is it??

Thank you for your help and sorry for my english.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 29, 2009 11:16 am     Reply with quote

Quote:
PIC 16F887
Compiler CCS 4.006 with mplab

That's an early version of the 4.xxx compiler. On this forum,
we know that you can't really use those early versions safely.
Alberto



Joined: 29 Sep 2009
Posts: 6

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 2:12 am     Reply with quote

Thank you for your answer, I know that but it seems to me that I must go on with this compiler.

I keep this array and seems to work fine.

Now I have another question: I include the ERRORS statement in the #use rs232 and my occuped ROM goes from 73% to 95%, is this fine? what ERRORS do to spend so much memory?

thank you very much!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 2:45 am     Reply with quote

Quote:
Not enough RAM for all variables

Use the forum's search engine to search for the error message.
Set it to "Search for all terms". Search page:
http://www.ccsinfo.com/forum/search.php

There are many, many threads on this problem. Here is one of them:
http://www.ccsinfo.com/forum/viewtopic.php?t=26147

Also, bookmark the FAQ page. It lists solutions for common problems:
http://www.ccsinfo.com/faq
Alberto



Joined: 29 Sep 2009
Posts: 6

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 3:14 am     Reply with quote

I spend hours searching about NOT ENOUGH RAM and I do the *=16 thing and I put the #separate statement, I give up my problem with RAM, I added this array of 32 and works fine.

now I´m only questioning if it is normal that:

Code:

#use rs232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)


Memory usage: ROM=73% RAM=49% - 82%

and if I add the ERRORS statement:
Code:

#use rs232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7, ERRORS)


Memory usage: ROM=95% RAM=49% - 82%

I want to know why the ERRORS statement makes the ROM increase so much


I also have tried to search about this thing but I haven´t found anything, thank you very much!!
Ttelmah
Guest







PostPosted: Wed Nov 04, 2009 3:39 am     Reply with quote

It almost certainly implies that you have large numbers of separate calls to the getc routines, each grows by only a small amount, but because you have a lot of calls, the total growth is big....

Best Wishes
Alberto



Joined: 29 Sep 2009
Posts: 6

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 5:18 am     Reply with quote

Thank you!

I have a state machine that works with interrupts and send & receive the communication and I only call getc and putc once in this function. It is true that I call this function with interrupts:

Code:


////////////////////////////////////////////////////////////////////////////////
//UART transmit interrupt
////////////////////////////////////////////////////////////////////////////////
#int_tbe
void uart_tx_handler(void)
   {
   evento_maquina_trama_actual = buffer_transmision_libre;
   sub_maquina_transmision_recepcion_trama();
   }

////////////////////////////////////////////////////////////////////////////////
//UART receive interrupt
////////////////////////////////////////////////////////////////////////////////
#int_rda
void uart_rx_handler(void)
   {
   evento_maquina_trama_actual = caracter_recibido;
   sub_maquina_transmision_recepcion_trama();
   }



void sub_maquina_transmision_recepcion_trama(void)

.....
.....
.....
case maquina_trama_emission:
         if (evento_maquina_trama_actual == buffer_transmision_libre)
            {
            if (indice_byte_trama<numero_de_bytes_de_la_trama+2)
               {
               putc(buffer_transmision_trama[indice_byte_trama]);
               indice_byte_trama++;
               }
            else if(indice_byte_trama >= numero_de_bytes_de_la_trama+2)
               {
               disable_interrupts(INT_TBE);
               init_and_start_t_3_5 ();
               };
            };
         if (evento_maquina_trama_actual == timeout_3_5)
            {
            estado_maquina_trama_actual = maquina_trama_idle;
            inicializacion_UART();
            evento_sub_maquina_idle = 1;
            evento_trama_enviada=1;
            };
         evento_maquina_trama_actual = no_evento;
         break;

case maquina_trama_reception:
         if (evento_maquina_trama_actual == caracter_recibido)
            {
            indice_byte_trama++;
            if (indice_byte_trama == BYTES_DATOS_EN_LA_TRAMA + 2) {indice_byte_trama = BYTES_DATOS_EN_LA_TRAMA + 1;};
            buffer_recepcion_trama[indice_byte_trama] = getc();
            init_and_start_t_3_5 ();
            init_and_start_t_1_5 ();
            }
         if (evento_maquina_trama_actual == timeout_1_5)
            {
            estado_maquina_trama_actual = maquina_trama_control_and_waiting;
            evento_flag_frame = control_frame();
            }
         evento_maquina_trama_actual = no_evento;
         break;

.....
.....
.....



maybe it is because I call with interrupts?
I have add // to these two instructions (putc and getc) and the ROM stills increases the same

It is also true that I call this function in other places, not with these cases, but I call it...

thank you for your time!!
Alberto



Joined: 29 Sep 2009
Posts: 6

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 7:04 am     Reply with quote

Hi!
I have been checking the .lst files and I realize that in all the whole program when I add the ERRORS statement the compiler TRIPLICATE some of the code lines, normally those related with I/O ports, what does it mean? what does the compiler do that?
please some ideas

thank you!!
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