|
|
View previous topic :: View next topic |
Author |
Message |
isaac aiyanyo Guest
|
Not enough ram for variables |
Posted: Tue Dec 17, 2002 10:00 am |
|
|
i am having this problems with my program.
i am using a 2D array for bit mapping the characters ABCD
i then try to copy this into a single dimesional array called
font.
But when i complier the program i get the error message
Error[74] 176 : Not enough RAM for all variables
i don't know what to do now so i included the program for your
help
Thanks in advance
Isaac
#include <16F876.H>
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,RESTART_WDT,ERRORS)
#IFNDEF EXP_OUT_ENABLE
#define EXP_OUT_ENABLE PIN_C2
#define EXP_OUT_CLOCK PIN_C1
#define EXP_OUT_DO PIN_C0
#define NUMBER_OF_74595 4
#ENDIF
#include <74595.C>
void Display(void) ;
#byte port_a=5
#byte port_c=7
#byte port_b=6
#define BUFFER_SIZE 16
byte buffer[BUFFER_SIZE];
byte Data [16];
byte next_in = 0;
byte next_out = 0;
char font [128]; // this the problem
char const pat[4][8]={
0,0xfc,0xfe,0x33,0x33,0xfe,0xfe,0, /* Fort A*/
0,0xff,0xff,0xdb,0xdb,0xff,0x66,0, /* Font B*/
0,0x7e,0xff,0xc3,0xc3,0xc3,0xc3,0, /* Font C*/
0,0xff,0xff,0xc3,0xc3,0xff,0x7e,0, /* Font D*/
};
// array holds the character maps for ABCD //
#int_rda
void serial_isr()
{
int t;
output_low(PIN_C4);
buffer[next_in]=getc();
t=next_in;
next_in=(next_in+1) \% BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}
#define bkbhit (next_in!=next_out)
byte bgetc()
{
byte c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) \% BUFFER_SIZE;
return(c);
}
main()
{
int i,z,ch,n;
set_tris_a(0);
set_tris_b(0);
set_tris_c(0b10000000);
delay_ms(10000); // 10 sec delay to enable lcd to start up
enable_interrupts(global); // enable global interupt
enable_interrupts(int_rda); // enable serial interupt
for(;;)
{
output_high(PIN_C4); //Turn on led on RC4 to tell us the pic is
//ready to receive data
printf("Powering up !!\r\n"); //Display this on hyperterminal
delay_ms(10000); //The program will delay for 10 seconds and then display
//any data that came in during the 10 second delay
printf("\r\nBuffered data => "); // display this to hypertherminal
while(bkbhit) // cheak if (bkbhit) is set or true
putc( bgetc() ); //if true there is data so display it
printf("\r\n"); //with carriage return and new line
// be displayed is the data received during int
// and not the ones received when displaying
#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)
// Now set the pins and data rate for the serial lcd on ra0
z=0;
for (i=0;i<16;i++) // loop 16 times though buffer[0]
{ // to buffer[15]
//putc(Data[i]); // display the characters in those locations
ch=buffer[i] - 65;
for (n=0;n<8;n++)
{
font[z]=pat[ch][n]; /// and here
z++;
}
} // on serial lcd connecte RA0
} display();
}
/////////////////////////// THE DISPLAY FUNCTION ///////////////////////////////////////////////
void Display(void)
{
int mask[4];
int data[4]; // array to store our data since i am
int delaycount;
int startposition;
int index;
int J;
signed int down;
port_c = 0;
port_b = 0;
startposition = 0;
for(;;) // start indefinate loop.
{
delaycount = 2; // adjust this value to control scrolls speed
while (delaycount)
{
index = startposition;
mask[0]=0x01; // Initialize our mask
mask[1]=0x00;
mask[2]=0x00;
mask[3]=0x00;
down=-1;
for (J=0; J<32; J++) // we have 32 columns to drive
{
// store our mask in an array. we need to do this because
// the call to write_expanded_outputs will destroy the value
// passed in.
data[0] = mask[0]; // store which column we are driving
data[1] = mask[1]; // in an array
data[2] = mask[2];
data[3] = mask[3];
index = J + startposition; // point to the next pattern to display
if (index >= sizeof(pat)) // make sure that we don't exceed the array
index -= sizeof(pat);
port_b = 0; // disable driving the LEDs
write_expanded_outputs(data); // enable our column driver
port_b = font[index]; // drive our LEDs
// i run out of ram
if (shift_left(mask,4,0))
mask[0] = 0x01;
// shift to the next column for next time
delay_us(700); // adjust this value to control the drive time
//for the leds
}
--delaycount; // decrement our delay loop counter
}
++startposition; // Point to the next data pattern
if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
{
startposition = 0;
}
}
}
////////////////////////////// END OF DISPLAY FUNCTION /////////////////////////////////////////
___________________________
This message was ported from CCS's old forum
Original Post ID: 10091 |
|
|
Richard Slater
Joined: 08 Sep 2003 Posts: 12 Location: Cambridge, UK
|
Re: Not enough ram for variables |
Posted: Tue Dec 17, 2002 10:50 am |
|
|
Hi there,
Have you tried the '#device *=16' directive, as this tells the compiler to use 16 bit pointer values rather than the default of eight. This increases the amount of RAM which is accessible, at the cost of speed and program size.
Hope this is some help.
Richard
:=
:= i am having this problems with my program.
:= i am using a 2D array for bit mapping the characters ABCD
:= i then try to copy this into a single dimesional array called
:= font.
:= But when i complier the program i get the error message
:= Error[74] 176 : Not enough RAM for all variables
:= i don't know what to do now so i included the program for your
:= help
:=
:= Thanks in advance
:= Isaac
:=#include <16F876.H>
:=#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
:=#use delay(clock=20000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,RESTART_WDT,ERRORS)
:=#IFNDEF EXP_OUT_ENABLE
:=#define EXP_OUT_ENABLE PIN_C2
:=#define EXP_OUT_CLOCK PIN_C1
:=#define EXP_OUT_DO PIN_C0
:=#define NUMBER_OF_74595 4
:=#ENDIF
:=#include <74595.C>
:=void Display(void) ;
:=
:=
:=#byte port_a=5
:=#byte port_c=7
:=#byte port_b=6
:=
:=
:=#define BUFFER_SIZE 16
:=byte buffer[BUFFER_SIZE];
:=byte Data [16];
:=byte next_in = 0;
:=byte next_out = 0;
:=char font [128]; // this the problem
:=char const pat[4][8]={
:=
:= 0,0xfc,0xfe,0x33,0x33,0xfe,0xfe,0, /* Fort A*/
:= 0,0xff,0xff,0xdb,0xdb,0xff,0x66,0, /* Font B*/
:= 0,0x7e,0xff,0xc3,0xc3,0xc3,0xc3,0, /* Font C*/
:= 0,0xff,0xff,0xc3,0xc3,0xff,0x7e,0, /* Font D*/
:= };
:= // array holds the character maps for ABCD //
:=
:=
:=#int_rda
:=void serial_isr()
:={
:=
:= int t;
:= output_low(PIN_C4);
:= buffer[next_in]=getc();
:= t=next_in;
:= next_in=(next_in+1) \% BUFFER_SIZE;
:= if(next_in==next_out)
:= next_in=t; // Buffer full !!
:=}
:=
:=#define bkbhit (next_in!=next_out)
:=
:=byte bgetc()
:={
:= byte c;
:=
:= while(!bkbhit) ;
:= c=buffer[next_out];
:= next_out=(next_out+1) \% BUFFER_SIZE;
:= return(c);
:=}
:=
:=
:=main()
:={
:= int i,z,ch,n;
:= set_tris_a(0);
:= set_tris_b(0);
:= set_tris_c(0b10000000);
:=
:= delay_ms(10000); // 10 sec delay to enable lcd to start up
:= enable_interrupts(global); // enable global interupt
:= enable_interrupts(int_rda); // enable serial interupt
:=
:= for(;;)
:= {
:= output_high(PIN_C4); //Turn on led on RC4 to tell us the pic is
:= //ready to receive data
:= printf("Powering up !!\r\n"); //Display this on hyperterminal
:=
:= delay_ms(10000); //The program will delay for 10 seconds and then display
:= //any data that came in during the 10 second delay
:= printf("\r\nBuffered data => "); // display this to hypertherminal
:= while(bkbhit) // cheak if (bkbhit) is set or true
:= putc( bgetc() ); //if true there is data so display it
:= printf("\r\n"); //with carriage return and new line
:=
:= // be displayed is the data received during int
:= // and not the ones received when displaying
:=#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_A1,RESTART_WDT,ERRORS,INVERT)
:= // Now set the pins and data rate for the serial lcd on ra0
:= z=0;
:= for (i=0;i<16;i++) // loop 16 times though buffer[0]
:= { // to buffer[15]
:= //putc(Data[i]); // display the characters in those locations
:= ch=buffer[i] - 65;
:= for (n=0;n<8;n++)
:= {
:= font[z]=pat[ch][n]; /// and here
:= z++;
:= }
:=
:= } // on serial lcd connecte RA0
:= } display();
:=
:=
:=
:=}
:=
:=/////////////////////////// THE DISPLAY FUNCTION ///////////////////////////////////////////////
:=
:=
:=void Display(void)
:={
:=int mask[4];
:=int data[4]; // array to store our data since i am
:=int delaycount;
:=int startposition;
:=int index;
:=int J;
:=signed int down;
:=
:=port_c = 0;
:=port_b = 0;
:=startposition = 0;
:= for(;;) // start indefinate loop.
:= {
:= delaycount = 2; // adjust this value to control scrolls speed
:= while (delaycount)
:= {
:= index = startposition;
:=
:= mask[0]=0x01; // Initialize our mask
:= mask[1]=0x00;
:= mask[2]=0x00;
:= mask[3]=0x00;
:= down=-1;
:= for (J=0; J<32; J++) // we have 32 columns to drive
:= {
:= // store our mask in an array. we need to do this because
:= // the call to write_expanded_outputs will destroy the value
:= // passed in.
:= data[0] = mask[0]; // store which column we are driving
:= data[1] = mask[1]; // in an array
:= data[2] = mask[2];
:= data[3] = mask[3];
:= index = J + startposition; // point to the next pattern to display
:= if (index >= sizeof(pat)) // make sure that we don't exceed the array
:= index -= sizeof(pat);
:= port_b = 0; // disable driving the LEDs
:= write_expanded_outputs(data); // enable our column driver
:= port_b = font[index]; // drive our LEDs
:= // i run out of ram
:=
:= if (shift_left(mask,4,0))
:= mask[0] = 0x01;
:= // shift to the next column for next time
:= delay_us(700); // adjust this value to control the drive time
:= //for the leds
:= }
:= --delaycount; // decrement our delay loop counter
:= }
:= ++startposition; // Point to the next data pattern
:= if (startposition >= sizeof(pat)) // make sure that we don't exceed the array
:= {
:= startposition = 0;
:=
:= }
:=
:= }
:=
:=}
:=
:=
:=
:=
:=////////////////////////////// END OF DISPLAY FUNCTION /////////////////////////////////////////
___________________________
This message was ported from CCS's old forum
Original Post ID: 10092 |
|
|
sar
Joined: 08 Sep 2003 Posts: 36
|
Re: Not enough ram for variables |
Posted: Tue Dec 17, 2002 12:02 pm |
|
|
Take a look at your sizeof statement.....something not right there.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10095 |
|
|
Chang-Huei Wu Guest
|
Re: Not enough ram for variables |
Posted: Tue Dec 17, 2002 7:04 pm |
|
|
char font [128]; // this the problem
368 bytes RAM of F876 are divided into 4 banks
the largest bank has only 96 bytes,
there's no way for any single variable to occupy
more than 96 bytes of RAM
try : char font [80];
or: 18F252
best wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 10107 |
|
|
|
|
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
|