Ivan-Holm
Member level 5
the code works fine with out float to show the int number of the ADC, but when I want to use float it works for a little bit time, and then Crash the Program and the micro P stop.
the code print the voltage i Volt, with to decimal after. on a 4 x 20 ascii Display. and have hit the wall :bang: to come op what to do. even #include<float.h> the Pic is an Pic18f242
define
the code print the voltage i Volt, with to decimal after. on a 4 x 20 ascii Display. and have hit the wall :bang: to come op what to do. even #include<float.h> the Pic is an Pic18f242
define
Code:
//*************Analog*****************
#define analog1 ADCON0 = 0x85;
#define analog2 ADCON0 = 0x8d;
#define analog3 ADCON0 = 0x95;
#define analog4 ADCON0 = 0x9d;
//#define analogon ADCON0bits.GO_DONE
//*******************Global variabler***********
char lcdtext[16];
int line,L;
float volt;
int An;
float vdd10bit = 4.75/1023;
Code:
//************ analog read ***
int AnalogRead(int ch)
{
if(ch==1)
{
analog1;
}
else if(ch==2)
{
analog2;
}
else if(ch==3)
{
analog3;
}
else if(ch==4)
{
analog4;
}
ADCON0bits.GO_DONE = 1;
// int An;
// for (An=0; An<1; An++)
// {
while(ADCON0bits.GO_DONE != 0)
{
blaa_on;
}
volt=(vdd10bit*(float)ADRES);
// volt=ADRES;
return (float)volt;
}