AnsweredAssumed Answered

Help me to use ADuC7024 Temp Sensor

Question asked by TiagoR on May 25, 2012
Latest reply on May 29, 2012 by AudeR

Hi,I'm just learning how to use ADuC and I want you to help me. Because I don't know how to understand all the code especially when it refers to ADCCON and ADCCP. Someone could explain a little bit?!. I'm having too some difficultis related to compile the code below. As you might know, this code it's aviable on datasheet pg 43. I tried to compile this code in KEIL 4, but appears some warnings such as:


temp sensor.c(8): warning:  #223-D: function "delay" declared implicitly

temp sensor.c(22): warning:  #223-D: function "floor" declared implicitly

temp sensor.c(32): warning:  #223-D: function "printf" declared implicitly







int main(void)


float a = 0;

short b;

ADCCON = 0x20; // power-on the ADC


ADCCP = 0x10; // Select Temperature

//Sensor as an input to the ADC

REFCON = 0x01; // connect internal 2.5Vreference // to Vref pin

ADCCON = 0xE4; // continuous conversion



while (!ADCSTA){};

// wait for end of conversion

b = (ADCDAT >> 16);

// To calculate temperature in °C, usethe formula:

a = 0x525 - b;

// ((Temperature = 0x525 - SensorVoltage) / 1.3)

a /= 1.3;

b = floor(a);

printf("Temperature: %doC\n",b);


return 0;