Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] DS18B20 temperature correct reading only in debug mode, not with production firmware

Status
Not open for further replies.

Drugo

Junior Member level 2
Joined
Feb 23, 2011
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,537
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. :bang:

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 :thumbsup:
 
Last edited:

ud23

Advanced Member level 3
Joined
Apr 20, 2011
Messages
926
Helped
184
Reputation
368
Reaction score
180
Trophy points
1,323
Activity points
6,138
post your code here.what is the bit resolution you set?
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Activity points
0
Zip and post the complete MPLAB X project files.
 

Drugo

Junior Member level 2
Joined
Feb 23, 2011
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,537
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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top