Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

at89c52 how to create function for saving memory space

Status
Not open for further replies.

numair_noor

Member level 2
Joined
Mar 15, 2012
Messages
50
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,715
hi, i have tried to create a program for password based security with lcd display.
i have used mikroc. it has built in lcd program for lcd commands. but it takes too much space every time i write lcd out command in my program.
my question:
1. i need a function which can show the output on lcd. using built in lcd_out command
for example:
void show();

void show(i)
{
LCD_OUT(2,1,ARRAY)
i++
}

so i can just put the function SHOW(); at anywhere and call this function saving my memory space. otherwise i run out of memory. my code is not finished yet. but i need to finish it as quickly as possible.
any assistance from any one is so welcome. thanks so much in advance.:)
CODE:

Code:
bit pass_flag;

 char kp[4];
 char amir[4]={'a','m','i','r'},asim[4]={'a','s','i','m'};//,asad[4]={'a','s','a','d'};//saeed[5]={'s','a','e','e','d'};
unsigned char i=0,j=0;
void name();
void Lcd_Init();
// Lcd module connections
sbit LCD_RS at P0_0_bit;
sbit LCD_EN at P0_1_bit;

sbit LCD_D4 at P0_2_bit;
sbit LCD_D5 at P0_3_bit;
sbit LCD_D6 at P0_4_bit;
sbit LCD_D7 at P0_5_bit;
// End Lcd module connections


void main()
{
//again:
p1=0x00;
p2=0x00;
p3=0x00;
//p0.B6=0;
//p0.b7=0;

Lcd_Init();                              // Initialize Lcd
Lcd_Cmd(_LCD_CLEAR);                     // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
LCD_OUT(1,1,"enter name");
delay_ms(500);
  while(1)
          {

pass_flag=0;
////////push buttons FUNCTIONS START////////////////
name();//enter name

//reg();//ENTER REGISTERATION NUMBER

          }

}



void name()         //function for registeration number
{

         for(i=0;i<4;i++)
         {
         while( p1==0x00 && (p3.b0!=1) && (p3.b1!=1) && (p3.b2!=1) && (p3.b3!=1) && (p3.b4!=1) && (p3.b5!=1) && (p3.b6!=1) && (p3.b7!=1)  )//; //wait for any key to be pressed        (p2.b0!=1) && (p2.b1!=1) && (p2.b2!=1) && (p2.b3!=1) && (p2.b4!=1) && (p2.b5!=1) && (p2.b6!=1) && (p2.b7!=1)
          //////////////////new start/////////////////
          if(p2.b0==1) //for a
                 {
                 //f=='0';
                 kp[i]='a';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"a"); //LCD OUT =a
                 while(p2.b0!=0);
                 }

         else if(p2.b1==1)   //for b
                 {
                 //f=='0';
                 kp[i]='b';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"b"); //LCD OUT =0
                 while(p2.b1!=0);
                 }


         else if(p2.b2==1)   //for d
                 {
                 //f=='0';
                 kp[i]='d';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"d"); //LCD OUT =0
                 while(p2.b2!=0);
                 }

         else if(p2.b3==1) //for l
                 {
                 //f=='0';
                 kp[i]='e';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"e"); //LCD OUT =0
                 while(p2.b3!=0);
                 }

         else if(p2.b4==1)   //for m
                 {
                 //f=='0';
                 kp[i]='i';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"i"); //LCD OUT =0
                 while(p2.b4!=0);
                 }


         else if(p2.b5==1)   //for m
                 {
                 //f=='0';
                 kp[i]='m';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"m"); //LCD OUT =0
                 while(p2.b5!=0);
                 }


         else if(p2.b6==1)   ///for n
                 {
                 //f=='0';
                 kp[i]='n';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"n"); //LCD OUT =0
                 while(p2.b6!=0);
                 }

         else if(p2.b7==1)   //////for r
                 {
                 //f=='0';
                 kp[i]='r';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"r"); //LCD OUT =0
                 while(p2.b7!=0);
                 }
        else if(p3.b7==1)   ////for s
                 {
                 //f=='0';
                 kp[i]='s';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"s"); //LCD OUT =0
                 while(p3.b7!=0);
                 }

        else if(p3.b6==1)   ////for t
                 {
                 //f=='0';
                 kp[i]='t';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"t"); //LCD OUT =0
                 while(p3.b6!=0);
                 }

          else if(p1.b0==1)    ////for 0
                 {
                 //f=='0';
                 kp[i]='0';       //put 0 in digit[i]
                 Lcd_Out(2,i+1,"0"); //LCD OUT =0
                 while(p1.b0!=0);
                 }

          else if(p1.b1==1)        //for 1
                 {
                 kp[i]='1';    //put 1 in digit[i]
                 LCD_OUT(2,i+1,"1");  //LCD OUT =1
                 while(p1.b1!=0);
                 }

          else if(p1.b2==1)        //for 2
                 {
                 //f=='2';
                 kp[i]='2';     //put 2 in digit[i]
                 LCD_OUT(2,i+1,"2");  //LCD OUT =2
                 while(p1.b2!=0);
                 }

          else if(p1.b3==1)        //for 3
                 {
                 kp[i]='3';        //put 3 in digit[i]
                 LCD_OUT(2,i+1,"3");//LCD OUT =3
                 while(p1.b3!=0);
                 }

          else if(p1.b4==1)        //for 4
                 {
                 kp[i]='4'; //put 4 in digit[i]
                 LCD_OUT(2,i+1,"4");//LCD OUT =4
                 while(p1.b4!=0);
                 }

          else if(p1.b5==1)        //for 5
                 {
                 kp[i]='5';//put 5 in digit[i]
                 LCD_OUT(2,i+1,"5");//LCD OUT =5
                 while(p1.b5!=0);
                 }

          else if(p1.b6==1) ///for 6
                 {
                 kp[i]='6';  //put 6 in digit[i]
                 LCD_OUT(2,i+1,"6");//LCD OUT =6
                 while(p1.b6!=0);
                 }

          else if(p1.b7==1)        //for 7
                 {

                 kp[i]='7';   //put 7 in digit[i]
                 LCD_OUT(2,i+1,"7");//LCD OUT =7
                 while(p1.b7!=0);
                }

          else if(p3.b0==1) //for 8
                 {
                 //f=='8';
                 kp[i]='8';    //put 8 in digit[i]
                 LCD_OUT(2,i+1,"8");//LCD OUT =8
                 while(p3.b0!=0);
                 }

          else if(p3.b1==1)        //for 9
                 {
                 //f='9';
                 kp[i]='9';   //put 9 in digit[i]
                 LCD_OUT(2,i+1,"9");//LCD OUT =9
                 while(p3.b1!=0);
                 }
          else if(p3.b2==1) //////////for *
                 {
                 //f=='8';
                 kp[i]='*';    //put 8 in digit[i]
                 LCD_OUT(2,i+1,"*");//LCD OUT =8
                 while(p3.b0!=0);
                 }

          else if(p3.b3==1)    /////for #
                 {
                 //f='9';
                 kp[i]='#';   //put 9 in digit[i]
                 LCD_OUT(2,i+1,"#");//LCD OUT =9
                 while(p3.b3!=0);
                 }
           /////////////////////name end before comparison/////////////
         }

//COMPARISON STARTING FROM HERE
        // if(pass_flag==0)
         //{
                    if( ( (kp[0]==amir[0])  &&  ( kp[1]==amir[1])   &&   ( kp[2]==amir[2]) )  ||   (  (kp[0]==asim[0])  &&  ( kp[1]==asim[1])   &&   ( kp[2]==asim[2]) )  )
                    {
                    //delay_ms(1000);
                    Lcd_Cmd(_LCD_CLEAR);
                    //delay_ms(1000);
                    Lcd_Out(1,4,"ENTER PASSWORD");
                    pass_flag=1;
                   // name();
                    }
                    //else
                    //{

                    //}
        // }
         //else if(name_flag==1&&pass_flag==1)
           //         {
             //       if(     (  (kp[0]==nasir[0])  &&  ( kp[1]==nasir[1])   &&   ( kp[2]==nasir[2]) )  ||      (  (kp[0]==basit[0])  &&  ( kp[1]==basit[1])   &&   ( kp[2]==basit[2]) )   ||   (  (kp[0]==imran[0])  &&  ( kp[1]==imran[1])   &&   ( kp[2]==imran[2]) )   ||   (  (kp[0]==saeed[0])  &&  ( kp[1]==saeed[1])   &&   ( kp[2]==saeed[2]) ) )
               //     {
                 //   Lcd_Cmd(_LCD_CLEAR);
 //                   Lcd_Out(2,5,"****");
   //                 delay_ms(2000);
     //               Lcd_Cmd(_LCD_CLEAR);
       //             Lcd_Out(1,4,"WELCOME");
         //           pass_flag=0;
           //         }
  //       else if(name_flag==1 && pass_flag==1)
    //                {

      //              }
}

I SHALL KEEP U UPDATED IF U WANT TO KNOW ANYTHING

I NEED TO CHANGE THIS PART:
Code:
else if(p3.b3==1)    /////for #
                 {
                 //f='9';
                 kp[i]='#';   //put 9 in digit[i]
                 LCD_OUT(2,i+1,"#");//LCD OUT =9
                 while(p3.b3!=0);
                 }

TO LIKE THIS:
Code:
else if(p3.b3==1)    /////for #
                 {
                 //f='9';
                 kp[i]='#';   //put 9 in digit[i]
                 show(char i,kp[i]);
                 while(p3.b3!=0);
                 }
etc.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top