toto_na16
Member level 1
Dear all,
I am using PIC16F877A to interface a password system and I wrote this code
I got this error " Not Enough RAM Istr_(code file name)"
does anyone know how to solve this problem ???
it seems that the MCU I am using doesn't have enough RAM ??????
I am using PIC16F877A to interface a password system and I wrote this code
Code:
char t;
char temp;
char ks[4];
char pp1[4];
char pp2[4];
char Ta[16]={'A','9','8','7','B','6','5','4','C','3','2','1','D','#','0','*'};
unsigned ec;
char factorypass[4]={'1','2','3','4'};
int flag;
int newflag;
int fcfp=0; // flag correct factory password
int compare(char*,char*);
void input(char*);
void main(){
// se eeprom add 0x00
Eeprom_Write(0x00,0);
// fu eeprom add 0x01
Eeprom_Write(0x01,0);
TRISD=0x00;
Lcd_Config(&PORTD,2,3,0,7,6,5,4);
LCD_Cmd(LCD_Cursor_Off);
Keypad_Init(&PORTC);
while(1){
if(Eeprom_Read(0x00)==1){
LCD_Cmd(LCD_Clear);
LCD_Out(1,3,"system error");
LCD_Out(2,3,"contact factory");
delay_ms(20);
break;
}
if(Eeprom_Read(0x01)==0){
while(fcfp==0){
LCD_Cmd(LCD_Clear);
LCD_Out(1,3,"enter factory");
LCD_Out(2,3,"password");
delay_ms(3000);
LCD_Cmd(LCD_Clear);
LCD_Chr(2,4,' ');
input(ks);
/*for(temp=0;temp<4;temp++){
ec=0;
while(ec==0)
ec = keypad_Released();
LCD_Chr_Cp('*');
t= Ta[ec-1];
ks[temp] = t;
}*/
/*for(temp=0;temp<4;temp++){
if(factorypass[temp]!=ks[temp])
{flag=1;}
}*/
flag = compare(factorypass,ks);
if(flag==1){
LCD_Cmd(LCD_Clear);
LCD_Out(1,3,"enter new");
LCD_Out(2,3,"password");
fcfp=1;
delay_ms(3000);
LCD_Cmd(LCD_Clear);
LCD_Chr(2,4,' ');
inputpp1: /*for(temp=0;temp<4;temp++){
ec=0;
while(ec==0)
ec = keypad_Released();
LCD_Chr_Cp('*');
t= Ta[ec-1];
pp1[temp] = t;
}*/
input(pp1);
LCD_Cmd(LCD_Clear);
LCD_Out(1,1,"enter the same");
LCD_Out(2,1,"password again");
delay_ms(3000);
LCD_Cmd(LCD_Clear);
LCD_Chr(2,4,' ');
/*for(temp=0;temp<4;temp++){
ec=0;
while(ec==0)
ec = keypad_Released();
LCD_Chr_Cp('*');
t= Ta[ec-1];
pp2[temp] = t;
}*/
input(pp2);
/*for(temp=0;temp<4;temp++){
if(pp1[temp]!=pp2[temp])
{newflag=1;}
}*/
newflag = compare(pp1,pp2);
if(newflag==1){
LCD_Cmd(LCD_Clear);
LCD_Out(1,1,"doesn't match");
LCD_Out(2,1,"enter again");
delay_ms(3000);
LCD_Cmd(LCD_Clear);
LCD_Chr(2,4,' ');
goto inputpp1;
}
if(newflag==0){
LCD_Cmd(LCD_Clear);
LCD_Out(1,1,"you have set");
LCD_Out(2,1,"new password");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////cpppppp
//////////////////////////////
///////////////////////////
////////////////////
}
}
if(flag==0){
LCD_Cmd(LCD_Clear);
LCD_Out(1,3,"wrong factory");
LCD_Out(2,3,"password");
delay_ms(2000);
LCD_Cmd(LCD_Clear);
LCD_Out(1,1,"enter correct");
LCD_Out(2,1,"factory password");
}
}
}
} /////main while end
} ///////////main func end
int compare(char* a,char* b){
int FF;
int i;
for(i=0;i<4;i++){
if(a[i]!=b[i])
{FF=1;
break;
}
}
return FF;
}
void input(char* c){
int j;
for(j=0;j<4;j++){
ec=0;
while(ec==0)
ec = keypad_Released();
LCD_Chr_Cp('*');
t= Ta[ec-1];
c[j] = t;
}
}
I got this error " Not Enough RAM Istr_(code file name)"
does anyone know how to solve this problem ???
it seems that the MCU I am using doesn't have enough RAM ??????