Ok,
Reading closer the datasheet shows there are time slots for writing and reading ...
so, rub out your PAUSE 2000 ...
but keep on polling DQ !
Alain
Ok,
Reading closer the datasheet shows there are time slots for writing and reading ...
so, rub out your PAUSE 2000 ...
but keep on polling DQ !
Alain
Last edited by Acetronics2; - 2nd October 2007 at 14:11.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Thanks again mate but your code, the code I tried last, didn't have a pause 2000. That was mine. Your code never gets past the wait loop either. Here is code again for clarity. I appreciate it isn't going to work later in code as I haven't done anything with offset etc but there is no point till I get past the wait loop for ds1820 to become ready.
Code:define OSC 48 ADCON1 = 7 ' Set PORTA to digital DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_SPBRG 225 ' 9600 Baud @ 48MHz, 0.0% SPBRGH = 4 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator HSEROUT [13,10,"Starting"] DQ var PORTA.0 temperature var word count_remain var word count_per_c var word offset var word '************************************************* **************************** ' Start temperature conversion '************************************************* **************************** mainloop: OWOut DQ, 1, [$CC, $44 ] '************************************************* **************************** ' Check for still busy converting ( ~ 4500 times ... ) '************************************************* **************************** waitloop: INPUT DQ If NOT DQ Then waitloop high PORTA.5 ' turn on LED if it gets past this point '************************************************* **************************** ' Read the temperature '************************************************* **************************** OWOut DQ, 1, [$CC, $BE ] OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c] '************************************************* **************************** ' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature) '************************************************* **************************** temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)+ offset Lcdout $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"C" '************************************************* **************************** ' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature) '************************************************* **************************** temperature = (temperature */ 461) + 3200 'Lcdout $fe, $c0, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"F" HSEROUT [13,10, " Temp = ",DEC (temperature / 100), ".", DEC2 temperature, " ","F"] goto mainloop
Try ADCON1 = 15 VS ADCON1 = 7. You are leaving most of PORTA setup as analog inputs.
Did you disable Porta Comparators ??? looks no ...
Default setting ... ok, but ...
EXAMPLE 10-1: INITIALIZING PORTA
CLRF PORTA ; Initialize PORTA by
; clearing output
; data latches
CLRF LATA ; Alternate method
; to clear output
; data latches
MOVLW 0Fh ; Configure A/D
MOVWF ADCON1 ; for digital inputs
MOVLW 07h ; Configure comparators
MOVWF CMCON ; for digital input
MOVLW 0CFh ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA<5:4> as outputs
Even Microchip does it !!! ...
Alain
Last edited by Acetronics2; - 2nd October 2007 at 17:11.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bruce/Alain THANKYOU SO MUCH!!
The ADCON1=15 did it and I also tried your ASM example Alain. They both fixed it. Sorry, I am new to this (well, 2 weeks new) and keep thinking I have the hang of it then learning more! I thought ADCON1=7 had disabled analogue inputs on all pins. I'll read that bit of DS before I go to bed so I have actually learnt it rather than having been spoon fed! Thanks!! OK, read it and learnt something very important. The DS is the bible, if only I could understand it!
Just read example 10.1. For the first time ever the example makes some sense to me and I can see why it is relevant to us PBPers. Wow!
I was just about to go to bed miserable. I got USB going today, wanted to feed temperature to VB instead of just my name. So much is coming together! 24LC256 challenge tomorrow!
Now I can wake up to a new day and a new phase of project!
THANKS SO MUCH
Rich
Bookmarks