We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
#define ADC_MOSI=P1^4; #define ADC_MISO=P1^3; #define p1first what is 'p1' if you want your code to be maintainable do not use upper/lower case as a determination.anyhow p1 (lowercase is used before it is defined
²erik malund this is an old thread; it's only been woken up by the spam post from Wicoevudd