but if I send adc data the loop stops at this.
Code: Select all
LCD.Write("DC Volts = ", DecToStr(ADVal / 100), ".", DecToStr(ADVal, 2), " ")
Here's whole code
Code: Select all
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 8/20/2015 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
Device = 18F2550
Clock = 20
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.1
#option LCD_EN = PORTB.2
// uses LCD and AD libraries...
Include "LCD.bas"
Include "utils.bas"
Include "ADC.bas"
Include "convert.bas"
// read the AD port and scale for 0 - 5 volts...
Function ADInAsVolt() As Word
result = (ADC.Read(0) + 1) * 500 / 1024
End Function
Dim ADVal As Word
// sampled AD value...
// initialise and clear LCD...
// PORTE as digital (LCD)
ADCON1 = %00001110
TRISA.0 = 1 // configure AN0 as an input
TRISB.0 = 0
DelayMS (500)
LCD.Cls
DelayMS (500)
LCD.MoveCursor (1,1)
LCD.Write ("alive")
// main program loop...
//portb.0 =1
While true
ADVal = ADInAsVolt
// portb.0 =1
DelayMS (250)
LCD.MoveCursor (2,1)
// portb.0 =1
LCD.Write("DC Volts = ", DecToStr(ADVal / 100), ".", DecToStr(ADVal, 2), " ") // stops here
PORTB.0 =1
DelayMS(250)
DelayMS (250)
PORTB.0 = 0
DelayMS (250)
Wend