This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Syntex error near(c141) error

I am using At89x52 microcontroller in the solar tracker.
I use the ADC MCP3208 to connect the two ldr and convert it into digital signal by ADC MCP 3208.

But,it shows syntex error in code. Help me with this


#include<at89x52.h>
#include<stdio.h>

#define ADC_CS=P1^5;
#define ADC_ClK P1^2;
#define ADC_MOSI=P1^4;
#define ADC_MISO=P1^3;
#define p1

sbit ADC_CLK = p1^2;
sbit ADC_MISO = P1^3;
sbit ADC_MOSI = P1^4;
sbit ADC_CS = P1^5;

void initSerial(void);
void write_adc_byte(char data_byte);
unsigned int ReadADC(unsigned char channel);
{
     {
          unsigned int adc_val=0;
          char i;

          ADC_CS=1;
          ADC_CLK=1;
          ADC_MOSI=1;
          ADC_MISO=1;

          ADC_CS=0;
          ADC_MOSI=1;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=1;
          ADC_CLK=1;

          ADC_MOSI=0;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=0;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=0;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          for(i=11;i>=0;i-)
          {
               ADC_CLK=0;

               if(ADC_MISO)
               adc_val|=(1<<i);

                ADC_CLK=1;
           }
           ADC_CS=1;

           temp1=((adc_val*5.0/4095);
           return temp1;
     }

     {
          unsigned int adc_val=0;
          float temp;
          char i;

          ADC_CS=1;
          ADC_CLK=1;
          ADC_MOSI=1;
          ADC_MISO=1;

          ADC_CS=0;
          ADC_MOSI=1;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=1;
          ADC_CLK=1;

          ADC_MOSI=0;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=0;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          ADC_MOSI=1;
          ADC_CLK=0;
          msdelay(100);
          ADC_CLK=1;

          for(i=11;i>=0;i-)
          {
               ADC_CLK=0;

               if(ADC_MISO)
               adc_val|=(1<<i);

                ADC_CLK=1;
           }
           ADC_CS=1;
           temp2=((adc_val*5.0/4095);
           return temp2;
     }
}

void init_uart()
{
     SCON=0X50;
     TMOD=0X20;
     TH1=OXFD;
     TR1=1;
     TI=1;
}

{
     if(temp1>temp2)
     {
           cw=0;
           ccw=1;
     }

     else if(temp1<temp2)
     {
           cw=1;
           ccw=0;
     }
     else
     {
          cw=0;
          ccw=0;
     }
}

if(cw==1)
{
     P1=OX66;
     msdelay(100);
     P1=OXCC;
     msdelay(100);
     P1=OX99;
     msdelay(100);
     P1=OX33;
     msdelay(100);
}

else if(ccw==1)
{
     P1=0X66;
     msdelay(100);
     P1=0X33;
     msdelay(100);
     P1=OX99;
     msdelay(100);
     P1=0XCC;
     msdelay(100);
}

void msdelay(unsigned int value)
{
     unsigned int x,y;
     for(x=0;x<1275;x++)
     for(y=o;y<value;y++);
}


Errors:

compiling NEWCODE1.c...

NEWCODE1.c(1): warning C500: MISSING LICENSE ID CODE (LIC) IN 'TOOLS.INI'

NEWCODE1.c(10): error C141: syntax error near '^', expected 'sizeof'

NEWCODE1.c(11): error C141: syntax error near '=', expected '<id>'

NEWCODE1.c(11): error C141: syntax error near '=', expected 'hdata'

NEWCODE1.c(11): error C129: missing ';' before '^'

Target not created.

Build Time Elapsed:  00:00:00

Help me with this.

Parents
  • What "help", exactly, do you need?

    Note that the number in brackets is the line number at which the error was found.
    So, for example:

    NEWCODE1.c(10): error C141: syntax error near '^', expected 'sizeof'
    


    refers to line 10 in the file NEWCODE1.c.

    It's easy for you to find that in the editor - not so much for people reading the forum.
    Especially as we can't be sure that you have given the whole file.

    So which line, exactly, is number 10 ?

    Take a look at that line, and think carefully whether you have got the syntax right ...

    Also consider that there could be something wrong in (a) previous line(s) which causes line 10 to no longer make sense ...

    As noted in your previous post, remember that the 'C' programming language is case-sensitive

    http://www.keil.com/forum/64348/

Reply
  • What "help", exactly, do you need?

    Note that the number in brackets is the line number at which the error was found.
    So, for example:

    NEWCODE1.c(10): error C141: syntax error near '^', expected 'sizeof'
    


    refers to line 10 in the file NEWCODE1.c.

    It's easy for you to find that in the editor - not so much for people reading the forum.
    Especially as we can't be sure that you have given the whole file.

    So which line, exactly, is number 10 ?

    Take a look at that line, and think carefully whether you have got the syntax right ...

    Also consider that there could be something wrong in (a) previous line(s) which causes line 10 to no longer make sense ...

    As noted in your previous post, remember that the 'C' programming language is case-sensitive

    http://www.keil.com/forum/64348/

Children