ok thanks bruce,
i tried the things you said, namely taking the a/d lines out, and the lcd was just as random. sometimes it would work.
strangly i changed the a/d bits from 8 to 10 as it is supposed to be (according to the datasheet) and then put the right justified bit on. and it worked very well!
i can now put my hands on the wires and the chip doesnt crash.
even more strangly though, when i put my probes on to measure the voltage on the temp sensor, it does the same thing. stops, gets stuck and then a second or so after i have take the probes off, it restarts. very odd.
it was a good idea to put that start text at the start because it turns out that all this time it was not 'stopping' it was continueously resetting. i changed from a crappy power supply to a battery, that made it even better.
now the only thing that stops it is the probs as i mentioned above. altohugh if i leave it running for an extended period of time, it eventually gets stuck.
one more thing, when i turn it on, the lcd screen sometimes just stays as black squares and other times it is fine. why is this? it seems random.
i can remember a while back, when i started using lcd screens they worked great, but recently as ive been playing with serial comms ive had all sorts of problems, with everything. it almost seems like a timing issue, because its happened so many times, and ive never sorted it.
sorry about this being so long
thanks
' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
'
' Connect analog input to channel-0 (RA0)
' Define LCD registers and bits
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
' Define ADCIN parameters
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
adval VAR WORD ' Create adval to store result
x VAR BYTE
temp VAR WORD
TRISA = %11111111 ' Set PORTA to all input
'TRISD = 0
ADCON1 = %10000011 ' Set PORTA analog and right justify result
Low PORTE.2 ' LCD R/W line low (W)
Pause 500
LCDOut $FE,1,"Start"
Pause 1000 ' Display sign-on message to 2S ' Wait .5 second
loop:
'adval = 0
'For x = 1 TO 100
ADCIN 0, adval ' Read channel 0 to adval
'adval = adval + temp
'Next x
'adval = adval/100
LCDOut $fe, 1 ' Clear LCD
LCDOut "Value: ", DEC adval ' Display the decimal value
'PORTD.1 = 1
Pause 100
'PORTD.1 = 0
Pause 100
GoTo loop ' Do it forever
End
Bookmarks