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++); }
For some reason, people seems to forget that it sometimes helps to perform a preprocessor expansion and look at what the "real" code actually looks like. That will quickly explain why the compiler is unhappy...
For some reason, people seems to forget
I'm regrettably sure it's worse than that. To be in a position to forget something, you have to know it first. The people we're dealing with here, never did.
This particular preprocessor mystery is a classic beginner's mistake; one which everyone has committed at least once in their career as a C programmer. The difference is in how you deal with it, and how often, until the lesson is fully learned: C compilers like their semicolons in exactly the right places, period.
www.8052.com/.../29152
Not specific to C51; Not specific to Keil; Not specific to embedded