I have been trying to run the following code:
void reset();
int board[8][8];
int i,switcher,j,k;
void main() {
TRISB = 0X00;
TRISD = 0X00;
TRISC = 0X00;
reset();
ADCON1 = 0X06;
TRISA =0X11;
while(1)
{
for( i=0;i<16;i++)
{
switcher = i;
PORTB.F0 = switcher%2;
switcher /= 2;
PORTB.F1 = switcher%2;
switcher /= 2;
PORTB.F2 = switcher%2;
switcher /= 2;
PORTB.F3 = switcher%2 ;
if (!PORTA.F0 == board[i/8][i%8])
break;
delay_ms(1000);
}
switcher = i;
PORTC.F0 = switcher%2;
switcher /= 2;
PORTC.F1 = switcher%2;
switcher /= 2;
PORTC.F2 = switcher%2;
switcher /= 2;
PORTC.F3 = switcher%2 ;
switcher /= 2;
PORTC.F4 = switcher%2;
switcher /= 2;
PORTC.F5 = switcher%2 ;
break;
}
}
void reset()
{
PORTB = 0;
PORTD = 0;
PORTC= 0;
}
On running this code, it's showing
"Not enough RAM" error.
However on running this code :
void reset();
int board[80][80];
void main() {
TRISB = 0X00;
TRISD = 0X00;
TRISC = 0X00;
reset();
ADCON1 = 0X06;
TRISA =0X11;
}
void reset()
{
PORTB = 0;
PORTD = 0;
PORTC= 0;
}
It runs successfully with no errors (Note that I am creating a multidimensional array of 80x80 whereas for the previous one it's only 8x8). Can someone help me in identifying the cause for the problem? And if possible then also the proper solution for the problem ?