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

ADC and LCD interfacing issue

I have written a code for getting input from ADC 0804 and then display the value on 16x2 lcd
I need help in writing a function to convert ADC output into a value which can be displayed in 16x2 lcd. ADC is used to convert temperature output from lm35. 5V supply voltage and Vref=2.5V.
I need code for - convert_display(value)
Also keil compiler gives error - adc_inter.c(16): error C141: syntax error near '='. I am unable to understand what should be done?

#include <reg51.h>
#include <stdio.h>
#include <string.h>
void msdelay(unsigned int time);
void convert_display(unsigned char value);
#define RD P2^5;
#define WR P2^6;
#define INTR P2^7;
unsigned long MYDATA;

void main()
{ unsigned char value; MYDATA = P1; MYDATA = 0xFF; INTR = 1; RD = 1; WR = 1; while(1) { WR=0; WR=1; while(INTR==1) { } RD=0; value=MYDATA; convert_display(value); RD=1; }
}

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

Parents
  • #include <reg51.h>
    #include <stdio.h>
    #include <string.h>
    void msdelay(unsigned int time);
    void convert_display(unsigned char value);

    int INTR;
    #define RD = P2^5
    #define WR = P2^6;
    unsigned long MYDATA;

    void main()
    { unsigned char value; RD = 1; WR = 1; INTR = P2^7; INTR = 1; MYDATA = P1; MYDATA = 0xFF; while(1) { WR=0; WR=1; while(INTR==1) { } RD=0; value=MYDATA; convert_display(value); RD=1; }
    }

    void convert_display(unsigned char value)
    { unsigned char x,d1,d2,d3; x=value/10; d1=value%10; d2=value/10; d3=x/10; P0=d1; msdelay(250); P0=d2; msdelay(250); P0=d3; msdelay(250);
    }

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

    Error is displayed at line 15,16,23,27,30. Error - "syntax error near '=' ".
    At every line I pass some int value to WR,RD, error is displayed.

Reply
  • #include <reg51.h>
    #include <stdio.h>
    #include <string.h>
    void msdelay(unsigned int time);
    void convert_display(unsigned char value);

    int INTR;
    #define RD = P2^5
    #define WR = P2^6;
    unsigned long MYDATA;

    void main()
    { unsigned char value; RD = 1; WR = 1; INTR = P2^7; INTR = 1; MYDATA = P1; MYDATA = 0xFF; while(1) { WR=0; WR=1; while(INTR==1) { } RD=0; value=MYDATA; convert_display(value); RD=1; }
    }

    void convert_display(unsigned char value)
    { unsigned char x,d1,d2,d3; x=value/10; d1=value%10; d2=value/10; d3=x/10; P0=d1; msdelay(250); P0=d2; msdelay(250); P0=d3; msdelay(250);
    }

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

    Error is displayed at line 15,16,23,27,30. Error - "syntax error near '=' ".
    At every line I pass some int value to WR,RD, error is displayed.

Children
  • #include <reg51.h>
    #include <stdio.h>
    #include <string.h>
    void msdelay(unsigned int time);
    void convert_display(unsigned char value);

    int INTR;
    #define RD = P2^5
    #define WR = P2^6
    unsigned long MYDATA;

    void main()
    { unsigned char value; RD = 1; WR = 1; INTR = P2^7; INTR = 1; MYDATA = P1; MYDATA = 0xFF; while(1) { WR=0; WR=1; while(INTR==1) { } RD=0; value=MYDATA; convert_display(value); RD=1; }
    }

    void convert_display(unsigned char value)
    { unsigned char x,d1,d2,d3; x=value/10; d1=value%10; d2=value/10; d3=x/10; P0=d1; msdelay(250); P0=d2; msdelay(250); P0=d3; msdelay(250);
    }

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

    Error - syntax error near '='.
    I think I'm making some mistake in passing value to RD,WR