#include<string.h>
#include<stdio.h>
#define __16f877A
#include"pic/pic16f877a.h"

//-----------------------Varables----------------------------//
//char x;
int dat;
int val;
int value;
int value1;
float value2;
int i;
char str[20];
//-----------------------Functions---------------------------//

//-------Delay-----------//
void delay1();
void delay2();

//-------Lcd------------//
void lcdinit();
void sendcom(char comm);
void busy();

//-------ADC-----------//
void adcinit();
void chselect();
void senddata(int dat);
void adc();
void multiply();
void mask();

//---------------------main function-------------------------//

void main(void)
{
PORTD=0x00;
PORTC=0x00;
TRISD=0x00;
TRISC=0x00;
delay1();
lcdinit();
adcinit();
while(1)
{
chselect();
delay2();
}

}
//---------------------lcd init function-----------------------//
void lcdinit()
{
 sendcom(0x3F);

 sendcom(0x3F);

 sendcom(0x3F);

 sendcom(0x3B);

 sendcom(0x08);

 sendcom(0x01);

 sendcom(0x02);

 sendcom(0x0C);

 sendcom(0x06);

}
//---------- Function to send command to lcd ----------------------//
void sendcom(char comm)
{
 TRISD=0x00;
 PORTC=0x04;                               // for command rs=0 rw=0 and
en=1(00000100)
 PORTD=comm;
 PORTC=0x00;                               //(00000000)
 busy();
 return;
}

//---------  Function To Check Whether The Lcd Is Busy -------------//
void busy()
{
 TRISD=0x80;
 PORTC =0x06;                             //00000110    for busy rs=0 rw=1
en=1
 _asm
 back2:
  BTFSC PORTD,7;
 goto back2;
 _endasm;
 PORTC = 0x00;    //0x02
 return;
}
//---------//---------  Function To Send Data To Lcd
------------------------//
void senddata(int dat)
{

TRISD=0x00;
PORTC=0x05;                                //for data rs=1 rw=0 en=1
(00000101)
PORTD=dat;
PORTC=0x01;
busy();
return;
}
//--------------------------Delay1----------------------------------//
void delay1()
{
TMR0=0xF0;
RP0=1;
PSA=0;
PS1=0;
T0CS=0;
RP0=0;

_asm
back3:
 BTFSS INTCON,2;
goto back3;
_endasm;

T0IF=0;
RP0=1;
T0CS=1;
RP0=0;
return;
}
//------------------------------Delay2---------------------//
void delay2()
{
 TMR1ON=1;
 TMR1H=0x09;
 TMR1L=0x00;
 T1CKPS0=1;
 T1CKPS1=1;
 TMR1CS=0;

 _asm
 back4:
  BTFSS PIR1,0;
 goto back4;
 _endasm;

 TMR1IF=0;
 TMR1ON=0;
 return;
}


//-------------------------Init A/D convertion-------------------//
void adcinit()
{
 ADCON1=0x84;
 ADON=1;
 ADCS1=1;
 ADCS0=0;
 return;
}
//------------------------Channel select------------------------//
void chselect()
{

 sendcom(0x80);
 senddata(0x43);
 senddata(0x48);
 senddata(0x30);
 senddata(0x3A);
 CHS2=0;
 CHS1=0;
 CHS0=0;
 adc();
 delay1();
 sendcom(0xC0);
 senddata(0x43);
 senddata(0x48);
 senddata(0x31);
 senddata(0x3A);
 CHS2=0;
 CHS1=0;
 CHS0=1;
 adc();
 delay1();
}
//------------------------Reading Data--------------------------//
void adc()
{
//ADCON0=0xA1;
 delay1();
 GO=1;
 _asm
 BACK1:
  BTFSC ADCON0,2;
 goto BACK1;
 _endasm;
 ADIF=0;
 mask();
 multiply();
 return;
}
//----------------------Convertion Of the Data---------------------//
void mask()
{
 value= ADRESH; //Getting the first digit
 value=value&0x03;
 value1=value;


 value=ADRESL;   //Getting the second digit
 value=value&0xF0;//swap is not included
 value1=value1*0x100+value;

 value=ADRESL;   //Getting the second digit
 value=value&0x0F;
 value1=value1+value;
 return;
}
void multiply()
{
// value1=0x00A;
value2=value1*0.00488758;

//-------First digit--------------------//
sprintf(str,"%f",value2);

for(i=0;i<strlen(str);i++)
  {
   val=str[i];
   senddata(val);
   }
return;
}

When i compiled the above program using sdcc
sdcc --debug -mpic14 -p16f877 progname.c
or
sdcc -mpic14 -p16f877 -I/usr/local/share/sdcc/include -L
/usr/local/share/sdcc/lib/ progname.c
or
sdcc -mpic14 -p16f877 progname.c

I get the following error in all the above case.

message: using default linker script "/usr/share/gputils/lkr/16f877.lkr"
error: missing definition for symbol "_strlen", required by "modiadc2lcd.o"
error: missing definition for symbol "_sprintf", required by "modiadc2lcd.o"

and the hex file is not generated asm and other codes are generated

plz help me to solve this.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to