SparkFun Forums 

Where electronics enthusiasts find answers.

By Drugo
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.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]