T3STY
Full Member level 4
- Joined
- Apr 17, 2012
- Messages
- 239
- Helped
- 24
- Reputation
- 48
- Reaction score
- 24
- Trophy points
- 1,308
- Activity points
- 3,715
I tried to declare a bidimensional array of chars of size [][16] which I will be using for storing the strings to display on a 16x2 LCD display. The code I'm using is this:
If the array is not used anywhere the compiler will only show a warning about it, then it will compile fine (probably it will skip compiling that array). If I try to use the array as a function parameter declaration (the block commented code after the main() function ) or as parameter of a function call (like LCD_WriteString(Menu[1]) ), the compiler will tell it can't find the necessary memory to allocate the array items for variable Menu. The output error is this:
When using the array as a function parameter declaration I may understand that the stack can get full with such a big array (even if I remember arrays are passed by reference/address, not copy of values). But even if I'm not using it as parameter, any call to the array will bring the error.
Now, I'm trying to understand what am I doing wrong for the compiler to complain about it. The whole code I wrote is not using all the available PIC memory, and the error before will show up even with an 'empty' program that only uses a function call with a call to an array item.
Could someone help me with this?
Thanks in advance.
Code:
#define _XTAL_FREQ 4000000
#include <htc.h>
__CONFIG(FOSC_XT & WDTE_OFF & PWRTE_ON & CP_OFF);
/* LCD DRIVER */
#include "HD44780.h"
#include "HD44780.c"
// note: strings are *NOT* NULL terminated !
char Menu[][16]={
"Item1",
"Item2",
"Item3",
"Item4"
};
void main(){
LCD_Initialize();
LCD_WriteString(Menu[1]);
while(1){
// do nothing
}
}
/*
// The same happens when using the array
// as function parameter declaration
void ShowMenu(char [][16]);
void ShowMenu(char M[][16]){
for (char c=0; c<4; c++){
LCD_Write(LCD_CLEAR);
LCD_WriteString(M[c]);
}
}
void main(){
LCD_Initialize();
ShowMenu(Menu);
while(1){
// do nothing
}
}
*/
Error [1250] C:\Users\T3STY\Documents\MPLAB\LCD V3\HD44780.c; 25. could not find space (64 bytes) for variable _Menu
********** Build failed! **********
When using the array as a function parameter declaration I may understand that the stack can get full with such a big array (even if I remember arrays are passed by reference/address, not copy of values). But even if I'm not using it as parameter, any call to the array will bring the error.
Now, I'm trying to understand what am I doing wrong for the compiler to complain about it. The whole code I wrote is not using all the available PIC memory, and the error before will show up even with an 'empty' program that only uses a function call with a call to an array item.
Could someone help me with this?
Thanks in advance.