EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / undefined identifier on KEIL Uvision4

undefined identifier on KEIL Uvision4

|

Microcontroller › 8051 › undefined identifier on KEIL Uvision4

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 6 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 14, 2014 at 8:24 am #2806
    wan akmal
    Participant

     

    i want to create the c programming for Micrcontroller AT89c51 for project digital code lock system. But the problem is it at:

     

    d c lock.c(222): error C202: ‘crystal’: undefined identifier
    d c lock.c(222): error C141: syntax error near ‘TL0’
     
    can you help me how to solve this problem
     

    #include <AT89X51.H>

    #define  EE_SCL   P1_0

    #define  EE_SDA   P1_1

    #define  LCD_E    P1_7

    #define  LCD_RW   P1_6

    #define  LCD_RS   P1_5

    #define  LCD_DATA P3

    #define buzz P0_3

    #define  led   P1_2

    void cmnwrt(int);

    void datawrt(char);

    char keypad_refresh();

    void init();

    void delay(unsigned i);

    void get_sntnc(char *);

    void print_msg(char*,char);

    void EE_write(unsigned int, char);

    char EE_read(unsigned int);

    void EE_strt();

    void EE_stop();

    char EE_shin();

    void EE_shout(char);

    //


    //


          

              int main(){

                char tmp[17],i,j;

     init();

                cmnwrt(0x80);

                 led=1;

                 while(1){

    if(EE_read(0) != ‘p’ || EE_read(1) != ‘=’){

    np:   

    cmnwrt(1);

    print_msg(“Enter new pass:”,0x80);

    get_sntnc(tmp);

    EE_write(0,’p’);

    EE_write(1,’=’);

    for(i=0; tmp; i++)

    EE_write(i+2,tmp);

    EE_write(i+2,0);

           }

    rpa:

                cmnwrt(1);

                print_msg(“Enter the pass:”,0x80);

              get_sntnc(tmp);

                  for(i=0,j=0;;i++){

                             if(tmp != EE_read(i+2)){

                                         j=-1;

                                        break;

                            }

                           if(!tmp)

                                        break;

         }

     

        cmnwrt(1);

        if(j==-1)

         {

        print_msg(“Pass is wrong!”,0x80);

              led=1;

        buzz=1;

                    delay(5000);

                   buzz=0;

                   goto rpa;

                    }

    else

           {

            print_msg(“Pass is right!”,0x80);

            led=0;

            buzz=0;

            delay(5000);

             led=1;

             }

     

             cmnwrt(1);

             print_msg(“*=change pass”,0x80);

             print_msg(“#=back”,0xc0);

     

    ka:

                   do

                                i=keypad_refresh();

                   while(i==-1);

     

                   if(i==0x3a)   

                            goto np;

                  else if(i==0x3c) 

                             goto rpa;

                  else

                              goto ka;

          }

    }

    //


    //


    void print_msg(char *msg, char line){

                   char i;

                cmnwrt(line);

                for(i=0; *(msg+i); i++)

                            datawrt(*(msg+i));

    }

    //


    //


     

    char keypad_refresh(){

                char tmp,row,cl;

    P2 = 0xf0;

                if(!P2_4)

                            row = 0;

                else if(!P2_5)

      row = 1;

                else if(!P2_6)

      row = 2;

                else if(!P2_7)

                            row = 3;

     else

                            return -1;

    P2 = 0xff;

    P2 = 0x0f;

     if(!P2_2)

                             cl = 0;

     else if(!P2_1)

      cl = 1;

     else if(!P2_0)

                            cl = 2;

                else

                            return -1;

    tmp = row*3+cl+1;

    if(tmp == 11)

                            tmp = 0;

     return tmp|0x30;

     

     

    }

    //


    //


     

    void get_sntnc(char *str) {

                char i,j,z;

     

                for(i=0; i<17; i++)

                             *(str+i) = 0;

     i=0;

     while(1){

                            cmnwrt(0xc0);

                for(z=0; z<16; z++)

                                          if(*(str+z))

                                                    datawrt(*(str+z));

                                         else

                                                      datawrt(‘ ‘);

     

                 delay(70);

                do

                            j = keypad_refresh();

                while(j==-1);

     

                if(j==0x3c){  

                            *(str+i) = 0;

                            break;

     

                 }else if(j==0x3a){ 

                          if(i>0){

                                         i–;

                                         *(str+i) = 0;

                              }

     

                 }else{

                              if(i<=15){

                                        *(str+i) = j;

                 i++;

                               }

            }

             }

     

    }

     

    //


    //


    void init() {

     int i;

     

     P0=P1=P2=P3=0;

     

    //initialize LCD

     

                LCD_RS = 0;

     LCD_RW = 0;

     

     delay(30);

                cmnwrt(0x3f);

     delay(20);

                cmnwrt(0x3f);

                delay(10);

                cmnwrt(0x3f);

     delay(5);

     cmnwrt(0x38);

     cmnwrt(0x01);

     cmnwrt(0x0c);

    //initialize EEPROM

     

     EE_SDA = 1;

     for (i=0; i<10; i++) {

                EE_SCL = 1;

                 i=i;                                                                              //delay

                 EE_SCL = 0;

            }

    }

     

    //


    //


     

    void delay(unsigned i) {

     

    TMOD = 1;

                for (;i>0;i–) {

                            TH0 = 0xFc;                 //0xFFFF – 0xFc17 = 1000 (decimal) -> 1ms for 12MH

    crystal

     TL0 = 0x17;

                             TR0 = 1;

    while(!TF0);

                            TR0 = 0;

                            TF0 = 0;

     }

    }

     

    //


    //


     

    void cmnwrt(int cmn) {

     

     LCD_DATA = cmn;

     LCD_RS = 0;

                LCD_RW = 0;

    LCD_E = 1;

                LCD_E = 0;

                delay(2);

    }

     

    void datawrt(char ch) {

     

     LCD_DATA = ch;

     LCD_RS = 1;

                LCD_RW = 0;

                LCD_E = 1;

                LCD_E = 0;

     delay(2);

    }

     

    //


    //


     

    //Write into EEPROM

    void EE_write(unsigned int addr, char dta){

                char chtmp;

                CY = 0;

                EE_strt();

     EE_shout(0xA0);

     chtmp = addr>>8;

                EE_shout(chtmp);

                chtmp = addr;

    EE_shout(chtmp);

     EE_shout(dta);

     EE_stop();

     

                delay(13);

    }

     

    //Reading from EEPROM

    char EE_read (unsigned int addr) {

                char chtmp;

                CY = 0;

                EE_strt();

     EE_shout(0xA0);

     chtmp = addr>>8;

     EE_shout(chtmp);

     chtmp = addr;

                EE_shout(chtmp);

                EE_strt();

     EE_shout(0xA1);

    chtmp = EE_shin();

     EE_stop();

     

                return chtmp;

     

    }

     

    //Start

    void EE_strt() {

     EE_SDA = 1;

                EE_SCL = 1;

                EE_SDA = 0;

     EE_SCL = 0;

    }

     

    //Stop

    void EE_stop() {

     EE_SCL = 0;

                EE_SDA = 0;

                EE_SCL = 1;

                EE_SDA = 1;

    }

     

    //Shift out

    void EE_shout(char sho) {

                unsigned char i,j;

     

     

     for (j=0, i=0; i<8; i++) {

                             j /= 2;

                            if (!j)

                                        j=128;

                             if (sho&j)

                                        CY = 1;

                            else 

                                            CY = 0;

                            EE_SDA = CY;

                            EE_SCL = 1;

                             j = j;                              //delay

                            EE_SCL = 0;

     }

     EE_SDA = 1;  

     EE_SCL = 1;

     j=j;                                            //delay

     CY = EE_SDA;

                EE_SCL = 0;

    }

     

    //Shift in

    char EE_shin() {

     char i,shi = 0;

     

     EE_SDA = 1;    

                for (i=0; i<8; i++) {

                             CY = 0;    

                 shi <<= 1;

                             EE_SCL = 1;

                             i=i;

                CY = EE_SDA;

                            EE_SCL = 0;

                            if (CY)

                                        shi++;

    }

     EE_SDA = 1;

     EE_SCL = 1;

     i=i;    //delay

     EE_SCL = 0;

     return shi;

    }

     

     

    January 15, 2014 at 4:04 am #10846
    AJISH ALFRED
    Participant

    Hi,

    It is a simple error occured due to improper commenting.

     

    TH0 = 0xFc;                 //0xFFFF – 0xFc17 = 1000 (decimal) -> 1ms for 12MH

    crystal

     TL0 = 0x17;

     

    Keep that ‘crystal’ on the same line where you started the comment, like given below.

     

    TH0 = 0xFc;                 //0xFFFF – 0xFc17 = 1000 (decimal) -> 1ms for 12MH crystal

    TL0 = 0x17;

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Charging shutdown circuit question. August 7, 2022
  • \Dim light short circuit tester August 7, 2022
  • Right channel distortion on vintage fisher rs-2010 August 7, 2022
  • Pedestal fan August 7, 2022
  • Automatic bartender machine audio decoration August 7, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools