Here's the problem:
#define LCD_DBIT = 0 ' Data bus 4, least significant bits of the port
#define LCD_DBIT = 4 'Data bus starts at bit 4, the most significant bits of the port
'Adaptation To LCD
'***********************************************************************
'Lines 3..8 copied from mikroBasic source code V_dBm_18F2550.pbas
'program V_dBm_18F2550
'Displays AD8307 Log.-Detector AC-in [dBm] versus DC-out [V] on LCD.
'MCU: PIC18F2550; Oscillator: HS, 20MHz; SW: mikroBasic build 7.0.0.2
'mikroBasic 4-bit default pin configuration for LCD initialization:
'D7, D6, D5, D4, EN, RS, RW - port(7..2, 0)
'Last change: 21.03.2010
'Using OshonSoft PIC18 Simulator IDE v5.72
'Options -> Configuration Bits -> Click "Generate Basic Code"
#define CONFIG1L = 0x00
#define CONFIG1H = 0x0C
#define CONFIG2L = 0x1E
#define CONFIG2H = 0x1E
#define CONFIG3L = 0x00
#define CONFIG3H = 0x83
#define CONFIG4L = 0x80
#define CONFIG4H = 0x00
#define CONFIG5L = 0x0F
#define CONFIG5H = 0xC0
#define CONFIG6L = 0x0F
#define CONFIG6H = 0xE0
#define CONFIG7L = 0x0F
#define CONFIG7H = 0x40
#define CLOCK_FREQUENCY = 20
#define STRING_MAX_LENGTH = 30
#define SINGLE_DECIMAL_PLACES = 2 ' Number of decimal places for floating point numbers
'#define SIMULATION_WAITMS_VALUE = 1 'Enable for simulation
'LCD Port ---------------------------------------------------
#define LCD_BITS = 4 'LCD data bus, configured To 4 bits
#define LCD_DREG = PORTB 'Data bus, assigned to port B
'#define LCD_DBIT = 0 ' Data bus 4, least significant bits of the port
#define LCD_DBIT = 4 'Data bus starts at bit 4, the most significant bits of the port
#define LCD_RSREG = PORTB 'RS control bit, assigned to port B
#define LCD_RSBIT = 1 'Bit RB1 assigned As RS
#define LCD_EREG = PORTB 'E control bit, assigned to port B
#define LCD_EBIT = 3 'Bit RB3 assigned as E
#define LCD_COMMANDUS = 2000 'Wait time after each command in microseconds
#define LCD_DATAUS = 100 'Wait time after sending data to the LCD in microseconds
#define LCD_INITMS = 50 'Wait time for display initialization in milliseconds
AllDigital
Lcdinit
Dim ZEROXING As Single 'Volts measured at AN0/RA0 for 0 dBm RF input
Dim SLOPE As Single 'Conversion slope measured as dB/V
Dim ADCResult As Single
'Dim 0ldResult As Single
Dim VoltsDisplay As String
Dim dBmResult As Single
Dim dBmDisplay As String
Dim x As Byte
x = 1
Dim Adc As Single
Adc = 5.25
main:
'Gosub GlobInit
Lcdcmdout LcdClear
WaitMs 100
'Lcdout " RF-Power Meter"
Lcd_Out(1, 1, " RF-Power Meter")
'Lcdcmdout LcdLine2Home
'Lcdout " Hardware Rev:4"
Lcd_Out(2, 1, " Hardware Rev:4")
WaitMs 100
Lcd_Out(2, 16, #x)
WaitMs 2000
Lcdcmdout LcdLine1Clear
Lcd_Out(1, 1, " " + #Adc + "V")
WaitMs 2000
Goto main
End
'Function Lcd_Out(line, pos, String_Value) de MicroBasic
Function Lcd_Out(line As Byte, pos As Byte, txt[20] As String) As Bit
If line = 0 Then line = 1
If line > 2 Then line = 2
If pos = 0 Then pos = 1
If line = 1 Then
Lcdcmdout LcdLine1Pos(pos)
Else
Lcdcmdout LcdLine2Pos(pos)
Endif
Lcdout txt
End Function