LPC54S018 Temperature sensor reading

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC54S018 Temperature sensor reading

1,337 Views
mh_n
Contributor III

Hello,
I am working with a LPC54S018 board and am using SDK (2.12.0) examples (I tried both "lpc_adc_basic" and "lpc_adc_interrupt") to read the value for the temperature sensor. When running the examples without modifying them, the reading is around 2759. I realized from UM11060 document that I should be using the adc channel 0, as a result, I changed the channel to 0 using the definitions at the top of the example and now can see values around 655. 

However, according to the data sheet "LPC540xx" (Table 55 and Figure 43 shown below) 655 would translate to about -32 degrees! (I am expecting a temperature about 23 degrees)

mh_n_0-1667845227921.png


Can you please let me know what I am doing wrong and how I can find the temperature in degrees?

Best Regards,

Mohammad

0 Kudos
Reply
5 Replies

1,319 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @mh_n ,

The value 655 is not voltage, it is just the  ADC result in ADC Data registers.

You can calculate the voltage refer to below:

Alice_Yang_0-1667977579997.png

Then refer to datasheet you mentioned to calculate temprature.

 

BR

Alice

 

0 Kudos
Reply

1,276 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @mh_n 

Pease see my first reply, Change 655 to Voltage, Then refer to datasheet you mentioned to calculate temperature. 

 

BR

Alice

0 Kudos
Reply

1,313 Views
mh_n
Contributor III

Hello @Alice_Yang ,

I have double checked using the debugger and I can see that the SDK example uses a function called "ADC_GetChannelConversionResult" from fsl_adc.c in which the data being read gets validated first ( using bit 31) and then only sets bits 15 to 4 to the result field.

Here is the the mentioned function (Line 570 does the part you had mentioned):

mh_n_1-1668005383065.png

The values of the constants are also below:

mh_n_2-1668005413847.png


However, I realized there is a ADC_CLOCK_DIVIDER constant in the SDK example's definitions which is set to 2, I was wondering if I would need to change that as well or not (since I had to change the channel number in there from 4 to 0)

0 Kudos
Reply

1,295 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @mh_n 

There is no issue with your result about  "around 655. ", this result is correct.

Why do you still want to change?  Do you have other issue?

 

BR

Alice

0 Kudos
Reply

1,289 Views
mh_n
Contributor III

Hello @Alice_Yang ,

As I had mentioned in my original post, the number 655 does not translate to the right temperature with NXP's documentation. Your last message implies that nothing is wrong.

As per document "LPC540xx_datasheet" (released on September 15th, 2020), section "12.3 Temperature sensor", Tables 54 and 55 as well as Figure 43, the number 655 that I am reading using the adc_basic example from SDK version 2.12.0, translates to about -32 Celsius!! (I am running this test in an office with a temperature about 21 Celsius).

In your last reply, you implied that 655 would be an expected value for a temperature measurement at room temperature. Clearly, as per the documentation, this is not! Is there something wrong with the board or the documentation or is the NXP software example not coded correctly?


Thank you,

Regards,

Mohammad

0 Kudos
Reply