Thanks for all your replies.
1. Mackrackit. Yes, there is a 10k pull-up on the data line.
2. Mr_e. Yes, OSC 32 is in the code.
3. Mr_e. OSC switchover to use a slower internal oscillator - how do you do this?
4. Sayzer. Use a timer interrupt to kill the WHILE. I think this is the best way to go but I'm not clear how to make the interrupt jump over the necessary lines. Can an interrupt direct the execution of the code to a label later in the program? I'd appreciate some advice. I am happy with both PBP and assembler coded interrupts.
The code bit causing the problem is:
Code:
' *****************************************************************************
' * *
' * READ SHT15. Using default setting of 12 bit humidity,14 bit temperature *
' * Because of the WHILE statemets, this hangs if the SHT15 is not conected *
' * *
' *****************************************************************************
ReadSensor:
gosub Initialise_SHT15
gosub Start_Sequence
shiftout DataPin,Clk,1,[SHTCommand\8] ' Send command byte %0000000011 or %000000101
input DataPin ' Wait for acknowledge
low Clk
while DataPin = 1 ' Sensor ACK by making Data = 0
wend
pulsout Clk,10 ' Send acknowledge
while DataPin = 0
wend
while DataPin = 1 ' Wait for conversion to complete
wend
low Clk
shiftin DataPin,Clk,0,[RawData.byte1\8] ' Get the first byte, 8 bits
low DataPin
pulsout Clk,10 ' Send acknowledge
shiftin DataPin,Clk,0,[RawData.byte0\8] ' Get the second byte, 8 bits
low DataPin
pulsout Clk,10 ' Send acknowledge
shiftin DataPin,Clk,0,[CRCsensirion\8] ' Get third byte, 8 bits, CRC
high DataPin
pulsout Clk,10 ' Send acknowledge
input DataPin ' End of Transmission
input Clk
return
If anyone is interested, I'm happy to post all the SHT15 code?
Regards Bill Legge
Bookmarks