Code: Select all
program EXPLogtest;
{ Declarations section }
var
Var1,Var2 : Real;
txt : Array[23] of Char;
// LCD module connections
var LCD_RS : sbit at LATD0_bit;
var LCD_EN : sbit at LATD2_bit;
var LCD_D4 : sbit at LATB4_bit;
var LCD_D5 : sbit at LATB5_bit;
var LCD_D6 : sbit at LATB6_bit;
var LCD_D7 : sbit at LATB7_bit;
var LCD_RS_Direction : sbit at TRISD0_bit;
var LCD_EN_Direction : sbit at TRISD2_bit;
var LCD_D4_Direction : sbit at TRISB7_bit;
var LCD_D5_Direction : sbit at TRISB6_bit;
var LCD_D6_Direction : sbit at TRISB5_bit;
var LCD_D7_Direction : sbit at TRISB4_bit;
// End LCD module connections
begin
Delay_ms(2000);
LATB := $0000;
TRISB := $0000;
ADPCFG := $FFFF; // PORTB is digital
LATD := $0000;
TRISD := $0000; // configure pins of portd as output
LCD_Init();
LCD_Cmd(_LCD_CURSOR_OFF);
While true do begin
Var1:=0.5;
FloatToStr(var1,txt);
LCD_out(1,1,txt);
Var2:=log(var1); //ln(0.5) should be -0.69314718
FloatToStr(var2,txt);
LCD_out(2,1,txt);
Var2:=log10(var1); //log(0.5) should be -0.3010210
FloatToStr(var2,txt);
LCD_out(2,10,txt);
Delay_ms(2000);
end;
end.