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++); }
Base 128 would imply that a 8-bit character larger than 127 would represent a printout of two ASCII characters - the high bit isn't allowed to just be masked away when talking about base-n numeric operations.
About printf() and 16-bit values - the language standard does cover multi-character character constants, but as implementation-defined.
I have a bit bad access to standard documents right now, but the old ISO 9899 standard (C99) has the following note (§6.4.4.4, bullet 10): "The value of an integer character constant containing more than one character (e.g., 'ab'), or containing a character or escape sequence that does not map to a single-byte execution character, is implementation-defined."
And J.3.4 covers implementation-specific behavior relating to characters: "The value of an integer character constant containing more than one character or containing a character or escape sequence that does not map to a single-byte execution character (6.4.4.4).
Character constants containing multiple characters are also a common cause for compilation warnings, because of the portability issues.