Connect with us

C129 error in keil C

Discussion in 'Microcontrollers, Programming and IoT' started by sahilt, Mar 29, 2013.

Scroll to continue with content
  1. sahilt

    sahilt

    8
    0
    Jul 23, 2012
    hey guys..i am currently working on a program on keil and i am not able to compile it coz everytime i try, i gives me an error C129: missing ';' before '\'. Can anyone plz help me? The program is as follows:

    rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}
    { \*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22 #include <reg51.h> \par
    //#include <header.h> \par
    //#include "lcd.h" \par
    #define adc_port P1\par
    #define lcd_port P2\par
    sbit rd=P3^7; //Read signal P3.7 \par
    sbit wr= P3^6; //Write signal P3.6 \par
    sbit cs= P3^5; //Chip Select P3.5 \par
    sbit intr= P3^4; //INTR signal P3.4 \par
    sbit rs= P3^0;\tab\tab //lcd_port P2 \par
    sbit rw= P3^1;\par
    sbit en= P3^2;\par
    sbit flag= P2^7;\par
    void conv(); //Start of conversion function\par
    void read();\par
    void delay(unsigned int);\par
    unsigned int adc_avg, adc; \par
    void wrt_cmd(unsigned char);\par
    void wrt_data(unsigned char);\par
    void wrt_string(unsigned char *);\par
    void LCD_INI(void);\par
    void busy(void);\par
    void hex2lcd(unsigned char);\par
    \par
    \par
    void main()\par
    \{\par
    unsigned char i,encoder;\par
    P1=0xff;\par
    P3=0x8f;\par
    P0=0x00; //output port\par
    \par
    LCD_INI();\par
    wrt_string("Voltage Display");\par
    while (1) //Forever loop\par
    \{ \tab\par
    \tab adc_avg = 0;\par
    \tab for (i = 0; i < 10; i++) \par
    \tab\{\par
    \tab\tab conv(); //Start conversion\par
    \tab\tab read(); //Read ADC\par
    \tab\tab adc_avg += adc;\par
    \tab\}\par
    adc_avg = adc_avg / 10;\par
    encoder=adc_avg&0xf0; //get high order 4 bit in encoder\par
    encoder=encoder>>4;\par
    P0=encoder;\par
    wrt_cmd(0xC0);\par
    wrt_string("V(DC): ");\par
    adc = adc_avg * 59;\par
    hex2lcd((unsigned char) (adc / 1000));\par
    wrt_data('.');\par
    adc = adc % 1000;\par
    hex2lcd((unsigned char) (adc / 10));\par
    wrt_data('V');\par
    \}\par
    \}\par
    \par
    void conv()\par
    \{\par
    cs = 0; //Make CS low\par
    wr = 0; //Make WR low\par
    wr = 1; //Make WR high\par
    cs = 1; //Make CS high\par
    while (intr); //Wait for INTR to go low\par
    \}\par
    void read()\par
    \{\par
    cs = 0; //Make CS low\par
    rd = 0; //Make RD low\par
    adc = adc_port; //Read ADC port\par
    rd = 1; //Make RD high\par
    cs = 1; //Make CS high\par
    \}\par
    /*\par
    void busy()\par
    \{\par
    flag = 1;\par
    rs = 0;\par
    rw = 1;\par
    while (flag != 0) \{\par
    en = 0;\par
    en = 1;\par
    \}\par
    \} */\par
    \par
    void wrt_cmd(unsigned char val_lcd)\par
    \{\par
    //busy();\par
    lcd_port = val_lcd;\par
    rs = 0;\par
    rw = 0;\par
    en = 1;\par
    en = 0;\par
    delay(500);\par
    \}\par
    \par
    void wrt_data(unsigned char dat)\par
    \{\par
    //busy();\par
    lcd_port = dat;\par
    rs = 1;\par
    rw = 0;\par
    en = 1;\par
    en = 0;\par
    delay(500);\par
    \}\par
    \par
    void wrt_string(unsigned char *string)\par
    \{\par
    while (*string)\par
    \tab wrt_data(*string++);\par
    \}\par
    \par
    void LCD_INI(void)\par
    \{\par
    wrt_cmd(0X38);\par
    wrt_cmd(0X38);\par
    wrt_cmd(0X38);\par
    wrt_cmd(0X38);\par
    wrt_cmd(0X06);\par
    wrt_cmd(0X0e);\par
    wrt_cmd(0X01);\par
    wrt_cmd(0X80);\par
    \}\par
    \par
    void delay(unsigned int i)\par
    \{\par
    while(i--);\par
    \}\par
    \par
    void hex2lcd(unsigned char hex)\par
    \{\par
    char temp1, temp2;\par
    temp1 = hex;\par
    temp2 = 0;\par
    do \{\par
    temp1 = temp1 - 100;\par
    if (temp1 >= 0)\par
    temp2++; \par
    \} while (temp1 >= 0);\par
    if (temp2 > 0)\par
    wrt_data(temp2 + 0x30);\par
    temp2 = 0;\par
    temp1 = temp1 + 100;\par
    do \{\par
    temp1 = temp1 - 10;\par
    if (temp1 >= 0)\par
    temp2++;\par
    \} while (temp1 >= 0);\par
    wrt_data(temp2 + 0x30);\par
    temp2 = temp1 + 10;\par
    wrt_data(temp2 + 0x30);\par
    \} \par
    }
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    Try:

    a) posting it again without the formatting
    b) telling us on which line it reports the error.
     
  3. sahilt

    sahilt

    8
    0
    Jul 23, 2012
    okk...thanks steve..,i'll do that...but its just reporting the error C129 on the very first line that is:

    rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\ f0\fnil\fcharset0 Calibri;}

    and i have no idea why this is happening... as i mentioned in my first post: C128 missing ';' before '\'
    Some help would be appreciated. Thanks in advance!!
     
    Last edited: Mar 30, 2013
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    I'm pretty sure your first line doesn't look like that.

    Perhaps you should try a plain ascii file, not what appears to be rtf.

    Using a PC? Copy and paste it into notepad.
     
  5. sahilt

    sahilt

    8
    0
    Jul 23, 2012
    oh!! ok...sorry if i did something wrong...i am simply copying and pasting my program in keil into the notepad. And when i try to look for the error ..all it points to is the very first line....dats wat i don't understand..

    rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}
    { \*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22
    //#include <reg51.h>
    //#include <header.h>
    //#include "lcd.h"
    #define adc_port P1
    #define lcd_port P2
    sbit rd=P3^7;
    sbit wr= P3^6;
    sbit cs= P3^5;
    sbit intr= P3^4;
    sbit rs= P3^0;
    sbit rw= P3^1;
    sbit en= P3^2;
    sbit flag= P2^7;
    void conv();
    void read();
    void delay(unsigned int);
    unsigned int adc_avg, adc;
    void wrt_cmd(unsigned char);
    void wrt_data(unsigned char);
    void wrt_string(unsigned char *);
    void LCD_INI(void);
    void busy(void);
    void hex2lcd(unsigned char);
    void main()
    {
    unsigned char i,encoder;
    P1=0xff;
    P3=0x8f;
    P0=0x00;
    LCD_INI();
    wrt_string("Voltage Display");
    while (1)
    {
    tab adc_avg = 0;
    for(i = 0; i < 10; i++)
    {
    conv();
    read();
    adc_avg += adc;
    }
    adc_avg = adc_avg / 10;
    encoder=adc_avg&0xf0;
    encoder=encoder>>4;
    P0=encoder;
    wrt_cmd(0xC0);
    wrt_string("V(DC): ");
    adc = adc_avg * 59;
    hex2lcd((unsigned char) (adc / 1000));
    wrt_data('.');
    adc = adc % 1000;
    hex2lcd((unsigned char) (adc / 10));
    wrt_data('V');
    }
    }
    void conv()
    {
    cs = 0;
    wr = 0;
    wr = 1;
    cs = 1;
    while (intr);
    }
    void read()
    {
    cs = 0;
    rd = 0;
    adc = adc_port;
    rd = 1;
    cs = 1;
    }
    void busy()
    {
    flag = 1;
    rs = 0;
    rw = 1;
    while (flag != 0)
    {
    en = 0;
    en = 1;
    }
    }
    void wrt_cmd(unsigned char val_lcd)
    {
    busy();
    lcd_port = val_lcd;
    rs = 0;
    rw = 0;
    en = 1;
    en = 0;
    delay(500);
    }
    void wrt_data(unsigned char dat)
    {
    busy();
    lcd_port = dat;
    rs = 1;
    rw = 0;
    en = 1;
    en = 0;
    delay(500);
    }
    void wrt_string(unsigned char *string)
    {
    while (*string)
    wrt_data(*string++);
    }

    void LCD_INI(void)
    {
    wrt_cmd(0X38);
    wrt_cmd(0X38);
    wrt_cmd(0X38);
    wrt_cmd(0X38);
    wrt_cmd(0X06);
    wrt_cmd(0X0e);
    wrt_cmd(0X01);
    wrt_cmd(0X80);
    }
    void delay(unsigned int i)
    {
    while(i--);
    }
    void hex2lcd(unsigned char hex)
    {
    char temp1, temp2;
    temp1 = hex;
    temp2 = 0;
    do {
    temp1 = temp1 - 100;
    if (temp1 >= 0)
    temp2++;
    } while (temp1 >= 0);
    if (temp2 > 0)
    wrt_data(temp2 + 0x30);
    temp2 = 0;
    temp1 = temp1 + 100;
    do {
    temp1 = temp1 - 10;
    if (temp1 >= 0)
    temp2++;
    } while (temp1 >= 0);
    wrt_data(temp2 + 0x30);
    temp2 = temp1 + 10;
    wrt_data(temp2 + 0x30);
    }
    }
     
    Last edited: Mar 30, 2013
  6. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    Delete these 2 lines and try again:

     
  7. sahilt

    sahilt

    8
    0
    Jul 23, 2012
    umm..i don't think so steve..but still as you suggested,i tried doing so and after compiling the program..it gave many more errors like:

    Build target 'Target 1'
    compiling trans1.c...
    TRANS1.C(6): error C202: 'P3': undefined identifier
    TRANS1.C(7): error C202: 'P3': undefined identifier
    TRANS1.C(8): error C202: 'P3': undefined identifier
    TRANS1.C(9): error C202: 'P3': undefined identifier
    TRANS1.C(10): error C202: 'P3': undefined identifier
    TRANS1.C(11): error C202: 'P3': undefined identifier
    TRANS1.C(12): error C202: 'P3': undefined identifier
    TRANS1.C(13): error C202: 'P2': undefined identifier
    TRANS1.C(27): error C202: 'P1': undefined identifier
    TRANS1.C(28): error C202: 'P3': undefined identifier
    TRANS1.C(29): error C202: 'P0': undefined identifier
    TRANS1.C(34): error C202: 'tab': undefined identifier
    TRANS1.C(34): error C141: syntax error near 'adc_avg'
    TRANS1.C(44): error C202: 'P0': undefined identifier
    TRANS1.C(57): error C202: 'cs': undefined identifier
    TRANS1.C(58): error C202: 'wr': undefined identifier
    TRANS1.C(59): error C202: 'wr': undefined identifier
    TRANS1.C(60): error C202: 'cs': undefined identifier
    TRANS1.C(61): error C202: 'intr': undefined identifier
    TRANS1.C(65): error C202: 'cs': undefined identifier
    TRANS1.C(66): error C202: 'rd': undefined identifier
    TRANS1.C(67): error C202: 'P1': undefined identifier
    TRANS1.C(68): error C202: 'rd': undefined identifier
    TRANS1.C(69): error C202: 'cs': undefined identifier
    TRANS1.C(73): error C202: 'flag': undefined identifier
    TRANS1.C(74): error C202: 'rs': undefined identifier
    TRANS1.C(75): error C202: 'rw': undefined identifier
    TRANS1.C(76): error C202: 'flag': undefined identifier
    TRANS1.C(78): error C202: 'en': undefined identifier
    TRANS1.C(79): error C202: 'en': undefined identifier
    TRANS1.C(85): error C202: 'P2': undefined identifier
    TRANS1.C(86): error C202: 'rs': undefined identifier
    TRANS1.C(87): error C202: 'rw': undefined identifier
    TRANS1.C(88): error C202: 'en': undefined identifier
    TRANS1.C(89): error C202: 'en': undefined identifier
    TRANS1.C(95): error C202: 'P2': undefined identifier
    TRANS1.C(96): error C202: 'rs': undefined identifier
    TRANS1.C(97): error C202: 'rw': undefined identifier
    TRANS1.C(98): error C202: 'en': undefined identifier
    TRANS1.C(99): error C202: 'en': undefined identifier
    TRANS1.C(146): error C141: syntax error near '}'
    Target not created

    so when i again included the lines, it gave back the same error..
    TRANS1.C(1): error C129: missing ';' before '\'
     
  8. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    Well, maybe there is something in those first 2 lines that are your actual code. I can't tell.

    Presumably you know what the code should look like, and presumably that alphabet soup isn't all part of it.

    But it is certainly true that P1, P2, etc do not appear to be defined.

    And what is interesting is that you assign values to them in code even though your gobal variables seem to have initial values based on their (undefined) values.

    I think these errors are real.
     
  9. sahilt

    sahilt

    8
    0
    Jul 23, 2012
    so...wat exactly do you mean by these errors are real..??
    And is there anyway you could suggest on how I could solve my problem??
     
  10. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,412
    2,780
    Jan 21, 2010
    The errors appear real because now the code appears wrong.

    Define P1 and P2 (etc) and some of your errors will go away.

    Then work on the rest.

    Perhaps one of those commented out includes contains the definitions. Why do you have them commented out?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-