I declared some variables and matrices globally in PIC16F887A code, but when I simulate that code on Proteus, one of the matrices doesn't exist in the "PIC CPU variables" window, while all the other variables and matrices exist. Why's that?
void burnLEd(unsigned char,unsigned char);
void display();
void find_Dir();
unsigned char matrix[8][8];
unsigned char len=4;
unsigned char max_len=32;
unsigned char btn=6;
unsigned char v_c=1;
unsigned char v_r=0;
unsigned char i=0;
unsigned char j=0;
char pos_c[10];
char pos_r[10];
void main()
{
TRISB=0; //output for matrix rows
TRISD=0; //output for matrix cols
TRISA=0; //output for keypad rows
TRISC=255; //input from kepad cols
PORTA=255;
PORTB=255;
PORTD=0;
//Matrix initial values to zero == all LEDs off
for(i=0; i<8; i++)
{ for(j=0; j<8; j++)
{ matrix[i][j]=0;
}
}
//Snake's initial configuration_________________________________________________
//setting its positions
for(i=0; i<len; i++)
{ pos_r[i]=7;
pos_c[i]=3-i;
}
//putting points onto Matrix
for(i=0; i<len; i++)
{ matrix[pos_r[i]][pos_c[i]]=1;
}
//main LOOP_____________________________________________________________________
while(1)
{ find_Dir();
//updating position of the head
pos_c[0]=pos_c[0]+v_c;
pos_r[0]=pos_c[0]+v_r;
//checking if snake's beyond the Screen
if(pos_c[0] > 7)
{ pos_c[0]=0;
}
else if(pos_c[0] < 0)
{ pos_c[0]=7;
}
if(pos_r[0] > 7)
{ pos_r[0]=0;
}
else if(pos_r[0] < 0)
{ pos_r[0]=7;
}
//updating rest of the body of snake
for(i=1; i<len; i++)
{ pos_c[i]=pos_c[i-1];
pos_r[i]=pos_r[i-1];
}
//putting positions on the Matrix
matrix[pos_r[0]][pos_c[0]]=1;
matrix[pos_r[len-1]][pos_c[len-1]]=0;
//Displaying on Matrix
for(i=0; i<2; i++)
{ for(j=0; j<2; j++)
{ display();
}
}
}
while(1);
}
void find_Dir()
{ PORTA=1;
if(PORTC == 2)
{ btn=2;
v_c=0;
v_r=-1;
return;
}
PORTA=2;
if(PORTC == 1)
{ btn=4;
v_c=-1;
v_r=0;
return;
}
if(PORTC == 4)
{ btn=6;
v_c=1;
v_r=0;
return;
}
PORTA=4;
if(PORTC == 2)
{ btn=8;
v_c=0;
v_r=1;
return;
}
PORTA=0;
}
void display()
{ for(i=0; i<8; i++)
{ for(j=0; j<8; j++)
{ if(matrix[i][j] == 1)
{ burnLED(i,j);
}
}
}
}
void burnLED(unsigned char row,unsigned char col) //PORTB=rows,PORTD=cols
{ PORTB=255 ^ (1<<row);
PORTD=0 | (1<<col);
Delay_ms(1);
}