Qaisar Azeemi
Member
Hi all;
i have interfaced lcd and adc with my 89c51 controller and want to make a digital thermometer, that display the temprature in both C and F scales. i write code for it but got the following problems.
DVM(8): error C202: 'Port': undefined identifier
DVM(9): error C202: 'Port': undefined identifier
DVM(10): error C202: 'Port': undefined identifier
DVM(11): error C202: 'Port': undefined identifier
DVM(12): error C202: 'Port': undefined identifier
DVM(13): error C202: 'Port': undefined identifier
DVM(14): error C202: 'Port': undefined identifier
DVM(35): error C202: 'RS': undefined identifier
DVM(36): error C202: 'E': undefined identifier
DVM(38): error C202: 'E': undefined identifier
DVM(49): error C202: 'RS': undefined identifier
DVM(50): error C202: 'E': undefined identifier
DVM(52): error C202: 'E': undefined identifier
DVM(59): error C141: syntax error near 'char', expected ')'
DVM(62): error C202: 'str': undefined identifier
DVM(64): error C202: 'str': undefined identifier
DVM(190): error C202: 'ALE': undefined identifier
DVM(191): error C202: 'SC': undefined identifier
DVM(194): error C202: 'ALE': undefined identifier
DVM(196): error C202: 'SC': undefined identifier
DVM(199): error C202: 'ALE': undefined identifier
DVM(201): error C202: 'SC': undefined identifier
DVM(213): error C202: 'test_inermediate2': undefined identifier
Target not created
i searched it out but cant solve it.
here is my code.......
please help me to solve my problem.
Thank you
i have interfaced lcd and adc with my 89c51 controller and want to make a digital thermometer, that display the temprature in both C and F scales. i write code for it but got the following problems.
DVM(8): error C202: 'Port': undefined identifier
DVM(9): error C202: 'Port': undefined identifier
DVM(10): error C202: 'Port': undefined identifier
DVM(11): error C202: 'Port': undefined identifier
DVM(12): error C202: 'Port': undefined identifier
DVM(13): error C202: 'Port': undefined identifier
DVM(14): error C202: 'Port': undefined identifier
DVM(35): error C202: 'RS': undefined identifier
DVM(36): error C202: 'E': undefined identifier
DVM(38): error C202: 'E': undefined identifier
DVM(49): error C202: 'RS': undefined identifier
DVM(50): error C202: 'E': undefined identifier
DVM(52): error C202: 'E': undefined identifier
DVM(59): error C141: syntax error near 'char', expected ')'
DVM(62): error C202: 'str': undefined identifier
DVM(64): error C202: 'str': undefined identifier
DVM(190): error C202: 'ALE': undefined identifier
DVM(191): error C202: 'SC': undefined identifier
DVM(194): error C202: 'ALE': undefined identifier
DVM(196): error C202: 'SC': undefined identifier
DVM(199): error C202: 'ALE': undefined identifier
DVM(201): error C202: 'SC': undefined identifier
DVM(213): error C202: 'test_inermediate2': undefined identifier
Target not created
i searched it out but cant solve it.
here is my code.......
Code:
#include <reg51.h>
#define port P3 // control port
#define adc_input P1
#define data_port P0 // data from microcontroller to LCD
sbit ADC_A=Port^0; //ADC
sbit ADC_B=Port^1; //ADC
sbit RS=Port^2; //LCD
sbit E=Port^3; //LCD
sbit SC=Port^4; //ADC
sbit CLK=Port^5; //ADC
sbit ALE=Port^6; //ADC
int test_intermediate3=0, test_final=0;
int test_intermediate1[10], test_intermediate2[3]={0,0,0};
//------------------- . ------------------
void delay(unsigned int msec)
{
int i,j;
for(i=0; i=msec; i++)
for(j=0; j=1275; j++);
}
//.................. LCD .................
void lcd_cmd( unsigned int item )
{
data_port=item; //command on data port p0 of lcd
RS=0; // selecting command register of lcd
E=1;
delay(1);
E=0;
return;
}
void lcd_data( unsigned int item )
{
data_port=item; //data on data port p0 of lcd
RS=1; // selecting data register of lcd
E=1;
delay(1);
E=0;
return;
}
void lcd_data_string(usinged char *str) // sending string to LCD
{
int i=0;
while (str[i] != '\0')
{
lcd_data(str[i]);
i++;
delay(10);
return;
}
}
//----------- custom character Generation for Degree symbol-----------
void shape()
{
lcd_cmd(64); // first location in CGRAM
lcd_cmd(2);
lcd_cmd(5);
lcd_cmd(2);
lcd_cmd(0);
lcd_cmd(0);
lcd_cmd(0);
lcd_cmd(0);
lcd_cmd(0);
return;
}
// Converting binary value of ADC to ASCII value of LCD
void convert()
{
int s;
lcd_cmd(0x81);
delay(2);
lcd_data_string("Temp: "); // Farnheit conversion
test_final=(((9*test_intermediate3)/5)+32);
s=test_final/100;
test_final=test_final%100;
lcd_cmd(0x88);
if (s!=0)
lcd_data(s+48);
else
lcd_cmd(0x06);
s=test_final/10;
test_final=test_final%10;
lcd_data(s+48);
lcd_data(test_final+48);
lcd_data(0);
lcd_data('F');
lcd_data(' ');
//------------------- for Celcius scale----------------
test_final=test_intermediate3;
lcd_cmd(0xC1); // set cursor to second line.
delay(2);
lcd_data_string("Temp: ");
s=test_final/100;
test_final=test_final%100;
lcd_cmd(0xc8);
if (s!=0)
lcd_data(s+48);
else
lcd_cmd(0x06);
s=test_final/10;
test_final=test_final%10;
lcd_data(s+48);
lcd_data(test_final+48);
lcd_data(0);
lcd_data('C');
lcd_data(' ');
delay(2);
}
//.........--------.......Main Program.......-------........
void main()
{
int i,j;
adc_input=0xff ; // making p1 as input port
lcd_cmd(0x38);
lcd_cmd(0x0c);
delay(2);
lcd_cmd(0x01);
delay(2);
while(1)
{
for(j=0;j<3;j++)
{
for(i=0;i<10;i++)
{
delay(1);
ALE=0;
SC=0;
delay(1);
ALE=1;
delay(1);
SC=1;
delay(1);
ALE=0;
delay(1);
SC=0;
delay(4);
lcd_cmd(0x88);
test_intermediate1[i]=adc_input/10;
delay(1);
}
for(i=0;i<10;i++)
test_inermediate2[j]+=test_intermediate1[i];
}
test_intermediate2[0]=test_intermediate2[0]/3;
test_intermediate2[1]=test_intermediate2[1]/3;
test_intermediate2[2]=test_intermediate2[2]/3;
test_intermediate3=test_intermediate2[0] + test_intermediate2[1] + test_intermediate2[2];
shape();
convert();
}
}
please help me to solve my problem.
Thank you
Last edited by a moderator: