SparkFun Forums 

Where electronics enthusiasts find answers.

Hello, I am experiencing a weird behavior with temperature readings from a DS18B20 Dallas temperature sensor. I am using a dsPIC33, ICD3 for debugging/downloading the firmware, XC16 compiler and I display the temperature on the console through serial port.
The problem is that I perfectly read the temperature in debug mode, while, in production mode, I read Temperature LSB and Temperature MSB of the scratchpad always equal to zero.

I am in big trouble because I have to deliver the firmware for the production next Tuesday. Could anyone please help me to fix this issue?

Thanks a lot in advance
Sorry but I don't get it very well. In the sense that, since I didn't post any code, how can Mee_n_Mac say that is line 42? I didn't post the code because I didn't do anything different from the other things I'm doing. In the sense that the instructions of this issue are the following:

printf("DS18B20 tempL = %u\n\r", tempL);
printf("DS18B20 tempH = %u\n\r", tempH);
printf("DS18B20 temperature = %f\n\r", temperature);

And, among these instructions, I tried to insert:
printf("DEBUG = %u\n\r", i);
and it works perfectly (i is a variable counter that I use in a for loop).

Any guess? Thanks so much for your help folks, I really appreciate
I got the final answer from the Microchip forum and want to post it for completeness. I am using AN5/IC8/CN7/RB5 pin to receive the digital data from the Dallas DS18B20 temperature sensor. In the inherited code I'm working on this pin was used as an analog one because the previous temperature sensor was analog. So, when it was analog, I found this initialization:

AD1PCFGLbits.PCFG5 = 1;

that I changed as digital in this way:

AD1PCFGLbits.PCFG5 = 0;

The mistake was that the initialization of this pin (as digital, in my current case) has to be:

AD2PCFGLbits.PCFG5 = 1;

In debug mode, as reported at page 20 of dsPIC33FJ128GP706A datasheet, all AN pins are configured by default as digital. So that's the reason why it worked in debug mode and not in production one.