Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

error of not enough RAM

Status
Not open for further replies.

hiral

New Member
hi

i am trying to develop c programing code for my weather program which is approximately 36kB long. i am using mikro c compiler and p89v51rd2fn micro controller for this purpose which has 64kb flash memory. though it has sufficient memory it gives error of not enough RAM code of my program ,library used and error list are as below


Code:
char GLCD_DataPort at P0;
sbit GLCD_CS1 at P2_0_bit;
sbit GLCD_CS2 at P2_1_bit;
sbit GLCD_RS  at P2_2_bit;
sbit GLCD_RW  at P2_3_bit;
sbit GLCD_EN  at P2_4_bit; 
sbit GLCD_RST at P2_5_bit;  
 int i=0,j,dir,k,l,p,hu,te,dot,pre; 
 char recv,ft[5];
 char t[]="*[MM00gdt]#" ;  
 char h[]="*[MM00gdr]#" ;   
 char pr[]="*[PP00gap]#"; 
 char wd[]="*[WW00gwd]#";
char ws[]="*[WW00gws]#" ;
void uart_init(unsigned char baud)
{TMOD=0x20;
PCON=0x00;
REN_bit=0X01;                
FE_SM0_bit=0x00;
SM1_bit=0x01;
TH1=baud;
TL1=baud;
TR1_bit=0x01;}
void w_p(char TX[]) 
{for(j=0;j<=10;j++)
{UART1_Write(TX[j]);}
i=0;
while(i<=22)
{if(UART1_Data_Ready())
{recv=UART1_Read();
if(i>=10&&i<=15)
ft[i-10]=recv;
i++;}}}
void main() 
{Glcd_Init();
Glcd_Fill(0);
uart_init(0xfd);
Glcd_Set_Font(System3x5,3,5,32);
Glcd_V_Line(0,19,0,1);// draw vertical & horizontal line for graph
Glcd_H_Line(0,47,19,1);
Glcd_V_Line(21,41,0,1);
Glcd_H_Line(0,47,41,1);
Glcd_V_Line(43,63,0,1);
Glcd_H_Line(0,47,63,1);
Glcd_Circle(100,20,15,1);
Glcd_Write_Text("N",100,0,1);
Glcd_Write_Text("S",100,4,1);
Glcd_Write_Text("E",117,2,1);
Glcd_Write_Text("W",80,2,1);
do
{
dot<<1;  // after 1 minute dot will be shifted in graph 
Glcd_Line(100,20,100,5,0); //it clear the line indicator of Cr. in wind direction
Glcd_Line(100,20,109,10,0);
Glcd_Line(100,20,85,20,0);
Glcd_Line(100,20,115,20,0);
Glcd_Line(100,20,109,30,0);
Glcd_Line(100,20,100,35,0);
Glcd_Line(100,20,91,30,0);
Glcd_Line(100,20,85,20,0);
Glcd_Line(100,20,91,10,0);
w_p(t);
Glcd_Write_Text("T",50,0,1); 
Glcd_Write_Text(ft,57,0,1);
te=atoi(ft);
dot=19-(te/3);
Glcd_Dot(k,dot,1);
w_p(h);
Glcd_Write_Text("H",50,1,1);
Glcd_Write_Text(ft,57,1,1);
hu=atoi(ft);
dot=41-(hu/5);
Glcd_Dot(k,dot,1);
w_p(pr);
Glcd_Write_Text("Pr",50,2,1);
Glcd_Write_Text(ft,57,2,1);
p=atoi(ft);
pre=1100-p;
dot=63-(pre/25);
Glcd_Dot(k,dot,1);
k++;
if(k==47)
k=0;
w_p(ws);
Glcd_Write_Text("WS",50,4,1);
Glcd_Write_Text(ft,57,4,1); 
w_p(wd);
Glcd_Write_Text("WD",50,3,1);
Glcd_Write_Text(ft,57,3,1);
dir=atoi(ft);
if((dir==0))
{Glcd_Line(100,20,100,5,1);}      
else if((dir>0)&&(dir<90))
{Glcd_Line(100,20,109,10,1);}       
else if(dir==90)
{Glcd_Line(100,20,115,20,1);}        
else if((dir>90)&&(dir<180))
{Glcd_Line(100,20,109,30,1);}      
else if(dir==180)
{Glcd_Line(100,20,100,35,1);}     
else if((dir>180)&&(dir<270))
{Glcd_Line(100,20,91,30,1);}     
else if(dir==270)
{Glcd_Line(100,20,85,20,1);}   
else if((dir>0)&&(dir<360))
{Glcd_Line(100,20,91,10,1);}
Delay_ms(60000); // 1 minute delay then again data will be taken.
}while(1);}


library used:

"__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_UART.mcl" "__Lib_CType.mcl" "__Lib_CStdlib.mcl" "__Lib_GlcdFonts.mcl" "__Lib_Glcd.mcl"

error:
Code:
line          message                  message text                         unit
              number

0            125               All files Preprocessed in 1 ms  
0            121               Compilation Started                         weather_1.c
108         122               Compiled Successfully                      weather_1.c
0            126               All files Compiled in 78 ms  
0            362               Not enough RAM '?lstr9_weather_1'     weather_1.c
0            102               Finished (with errors): 19 Oct 2010, 18:03:27
 
hi,
For PIC's the actual code memory is only half the size of the datasheet memory specified, this is because a program word occupies two bytes.
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    15.8 KB · Views: 325
Last edited:
RAM is not ROM, your MCU has only 1K RAM and depending on your compiler it may not be all available for user programs.
 
Last edited:
hi
thank you for replay but i am not using PIC controller it is NXP p89v51rd2fn from 8051 family.
 
hi
thank you for replay but i am not using PIC controller it is NXP p89v51rd2fn from 8051 family.

hi,
Downloaded the p89V51 datasheet.
The RAM is only 1024 bytes, you say the compiler reports 'insufficient RAM' , how many bytes of RAM is your program using.

Dont confuse the 64KB of program memory with the RAM size.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top