Hello,
i've been trying to work on this code for PIC12F675. Its pretty simple. It takes ADC signal on GP0 (LM35 temperature) and then sends it to the computer via GP1 and GP2 ports. The user is to be told to write the sampling time and the scale on serial communication to the computer.
Here's the problem, i get the message displayed but it just freezes when i should write the sampling time. What's wrong?. Can anybody help me to debug it?.
My version of PicBasic Pro is 2.60A
i've been trying to work on this code for PIC12F675. Its pretty simple. It takes ADC signal on GP0 (LM35 temperature) and then sends it to the computer via GP1 and GP2 ports. The user is to be told to write the sampling time and the scale on serial communication to the computer.
Here's the problem, i get the message displayed but it just freezes when i should write the sampling time. What's wrong?. Can anybody help me to debug it?.
My version of PicBasic Pro is 2.60A
Rich (BB code):
INCLUDE "modedefs.bas"
DEFINE OSC 4
DEFINE ADC_BITS 10 ' A/D bits
DEFINE ADC_CLOCK 3 ' A/D internal RC clock
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
Tsample VAR byte ' Sampling time in sec
Mode VAR Byte ' Mode (C or F)
Dummy VAR Byte
D VAR Byte ' Temperature mode display
CMCON=7
RS232_out var GPIO.2
RS232_in var GPIO.1
CR CON 13 ' Carriage-return character
LF CON 10 ' Line-feed character
Res Var Word
Temp1 Var Word
TRISIO.1 = 1 ' GP0 (AN0) is input, GP2 = output, GP1 = input
PAUSE 1000
Again:
SEROUT RS232_out, T2400, [LF,CR, "Digital Thermometer RS232 Output"]
SEROUT RS232_out, T2400, [LF,CR, "=============================="]
Esample:
SEROUT RS232_out, T2400, [LF,LF,CR, "Enter sampling interval in seconds : "]
SERIN RS232_in, T2400, 5000, ESample, #TSample
SEROUT RS232_out, T2400, [#Tsample]
EMode:
SEROUT RS232_out, T2400, [LF,CR, "Degrees C (C) or degrees F (F) : "]
SERIN RS232_in, T2400, 5000, EMode, Mode
SEROUT RS232_out, T2400, [Mode]
Estart:
SEROUT RS232_out, T2400, [LF,CR, "Press ENTER to start..."]
SERIN RS232_in, T2400, 5000, Estart, Dummy
SEROUT RS232_out, T2400, [LF,CR]
TSample = TSample*1000
ADCON0=%00000011
ANSEL=%000000001
More:
D = "C"
ADCIN 0, Res
Temp1 = 48 * Res
Temp1 = Temp1/100
IF Mode = "F" THEN
Temp1 = Temp1 * 18
Temp1 = Temp1 + 320
Temp1 = Temp1 / 10
D = "F"
ENDIF
SEROUT RS232_out, T2400, [LF,CR, #Temp1, D]
PAUSE Tsample
GOTO More
END