I am using debian etch l installed sdcc by apt-get install sdcc then
the installed version of sdcc is SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.6.0
#4309 (Oct 15 2006) (UNIX)
the stable one .when i compile a program for  A/D converion and to
display it on an lcd.It will generate a hex code of 361 lines.This hex
code when i burned it will not work.

Then i download a snapshot(DirectoryLinux on i386 (i386-unknown-linux2.3)
whoes version is SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.6.3
#4533 (Dec 29 2006) (UNIX)
and compile the same program it will generate a hex code of 631 line
and it works well .
I have also another problem
DirectoryLinux on i386 (i386-unknown-linux2.5) when i download
snapshot from here and i give the command ./sdcc-v from the bin
directory i get an error message "Floating point exception"

My c code  in the attachment

Plz Help me to solve this problem
#define __16f877A
#include"pic/pic16f877a.h"
#include<string.h>
#include<stdio.h>
//-----------------------Varables----------------------------//
int value1=0;
char str[14],str1[10];
//-----------------------Functions---------------------------//
void commandLCD(char comm);
void busy();
void lcdinit();
void writeLCD(char c);
void adcinit();
void adc();
void convert_float(float number);
void getadc();
void chselect();
void delay1(char time1);
void delay2(char time2);
//---------------------main function-------------------------//

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

}
//---------------------lcd init function-----------------------//
void lcdinit()
{ 
  commandLCD(0x2C); // Function to set 8 bit

  commandLCD(0x2C); // Function to set 8 bit 

  commandLCD(0x2C); // Function to set 8 bit

  commandLCD(0x01); // Function to clear

  commandLCD(0x0C); //Display ON, Cursor OFF, Blinking OFF 

  commandLCD(0x06); //cursor Home

} 
//---------- Function to send command to lcd ----------------------//

void commandLCD(char comm)
{
 TRISD=0x00;
 PORTD=(PORTD&15)|(comm&0xF0);
 PORTD=PORTD^0x04;               // for command rs=0 rw=0 and en=1(00000100)
 PORTD=0x00;
 PORTD=(PORTD&15)|(comm<<4);     
 PORTD=PORTD^0x04;
 PORTD=0x00;                     //(00000000)
 busy();
 return;
 }

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

//-------------------------- Send data --------------------------//
void writeLCD(char c)
{

 TRISD=0x00;
 PORTD=(PORTD&15)|(c & 0xF0);	//for data rs=1 rw=0 en=1 (00000101)
 PORTD=PORTD^0x05;
 PORTD=0x00;
 PORTD=(PORTD&15)|(c << 4);
 PORTD=PORTD^0x05;		//for data rs=1 rw=0 en=1 (00000101)
 PORTD=0x00;
 busy();
 return;
}
//--------------------------Delay1----------------------------------//
void delay1(char time1)
{
 TMR0=time1;//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(char time2)
{
  TMR1ON=1;
  TMR1H=time2;
  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()
{
  commandLCD(0x80);
  writeLCD(0x43); 
  writeLCD(0x48); 
  writeLCD(0x30);
  writeLCD(0x3A);
  CHS2=0;
  CHS1=0;
  CHS0=0;
  adc();
  delay1(0xF0);
  commandLCD(0xC0);
  writeLCD(0x43); 
  writeLCD(0x48); 
  writeLCD(0x31); 
  writeLCD(0x3A); 
  CHS2=0;
  CHS1=0;
  CHS0=1;
  adc();
  delay1(0xF0);
}
//-------------------------Reading Data----------------------------//
void adc()
{
  delay1(0xF0);
  GO=1;
  _asm
  BACK1:
   BTFSC ADCON0,2;
  goto BACK1;
  _endasm;
  ADIF=0;
  getadc();
  return;
}
//----------------------Convertion Of the Data---------------------//
void getadc()
{
  value1=ADRESH&0x03;//Get the first digit

  value1=value1*0x100+ADRESL;   //Getting the second digit
  convert_float(value1*0.004887856);
  return; 
}
void convert_float(float number)
{
 int  i=0;
 char k=0;
 char u=3;
 if(number==0)
 {
 str[i]='0';
 i++;
 u=0;
 k=4;
 }
 while(number<1&&number!=0)
 {
  number=number*10;
  k++;
 }
 number=number*1000;
 while(number>=1)
 {
 str[i]=48+(int)number%10;
 number=(int)number/10;
 i++;
 }
 while(k>0)
 {
 str[i]='0';
 i++;
 k--;
 u++;
 } 
 while(i>0)
 {
 if(i==u)
 writeLCD('.'); 
 i--;
 writeLCD(str[i]);
 } 

}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to