LPC55S69 internal temperature sensor

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC55S69 internal temperature sensor

ソリューションへジャンプ
3,204件の閲覧回数
Fastfox
Contributor II

I am trying to read MCU temperature with the example I found from SDK(lpadc_temperature_measurement). When I run the measurement approximately once/s, result seems to toggle between two values that are 3.5C degrees apart from each other. ADC results are not changing that much, but final temperature is. I tried to compare the example formula to what the datasheet says and I also replicated the formula to libre calc and the results are the same. Changing the ADC result with just one bit, changes to output several degrees. Example output:


0x147E(5246) Shifted:0x28F
0x161A(5658) Shifted:0x2C3
Temp: 27.504

0x147E(5246) Shifted:0x28F
0x161B(5659) Shifted:0x2C3
Temp: 27.504

0x1481(5249) Shifted:0x290
0x161D(5661) Shifted:0x2C3
Temp: 23.917

0x1483(5251) Shifted:0x290
0x161F(5663) Shifted:0x2C3
Temp: 23.917

0x1484(5252) Shifted:0x290
0x161F(5663) Shifted:0x2C3
Temp: 23.917

0x1485(5253) Shifted:0x290
0x161E(5662) Shifted:0x2C3
Temp: 23.917

0x1485(5253) Shifted:0x290
0x1620(5664) Shifted:0x2C4
Temp: 27.242

Read it like this:

ADC_conv_result1_hex(ADC_conv_result1_dec) Shifted:3bit_shifted_result1_hex
ADC_conv_result2_hex(ADC_conv_result2_dec) Shifted:3bit_shifted_result2_hex
Temp: Output of the formula

So feeding e.g. 0x28F and 0x2C3 to the formula gives 23.917C and feeding 0x290 and 0x2C3 gives 27.242.

My question is that is this really the accuracy that one should expect or is the calculation in example and in datasheet somehow incorrect?

0 件の賞賛
返信
1 解決策
3,167件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Fastfox,

Yes, the  temperature accuracy is +/- 4 C.

And I test the SDK demo lpcxpresso55s69_lpadc_temperature_measurement on LPCxpresso55s69 demo board, the temperature result is the same:

 

 

Alice_Yang_0-1633681712680.png

 

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
3,168件の閲覧回数
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Fastfox,

Yes, the  temperature accuracy is +/- 4 C.

And I test the SDK demo lpcxpresso55s69_lpadc_temperature_measurement on LPCxpresso55s69 demo board, the temperature result is the same:

 

 

Alice_Yang_0-1633681712680.png

 

0 件の賞賛
返信
3,161件の閲覧回数
frank_m
Senior Contributor III

I did not work with the LPC55S MCUs yet, but that does not make much sense to me. At least comparing with other internal temprature sensors.

The operating temperature range of the MCU is specified as -40...+105°C, giving about 145/4 = 38,5 steps, i.e. about 5 bit.

0 件の賞賛
返信
3,176件の閲覧回数
Fastfox
Contributor II

Here is the code. This is not exactly "my code", but straight from the SDK example.

float DEMO_MeasureTemperature(ADC_Type *base, uint32_t commandId, uint32_t index)
{
	g_LpadcConversionCompletedFlag = false;
    lpadc_conv_result_t convResultStruct;
    uint16_t Vbe1            = 0U;
    uint16_t Vbe8            = 0U;
    uint32_t convResultShift = 3U;
    float parameterSlope     = DEMO_LPADC_TEMP_PARAMETER_A;
    float parameterOffset    = DEMO_LPADC_TEMP_PARAMETER_B;
    float parameterAlpha     = DEMO_LPADC_TEMP_PARAMETER_ALPHA;
    float temperature        = -273.15f; /* Absolute zero degree as the incorrect return value. */

#if defined(FSL_FEATURE_LPADC_TEMP_SENS_BUFFER_SIZE) && (FSL_FEATURE_LPADC_TEMP_SENS_BUFFER_SIZE == 4U)
    /* For best temperature measure performance, the recommended LOOP Count should be 4, but the first two results is
     * useless. */
    /* Drop the useless result. */
    (void)LPADC_GetConvResult(base, &convResultStruct, (uint8_t)index);
    (void)LPADC_GetConvResult(base, &convResultStruct, (uint8_t)index);
#endif /* FSL_FEATURE_LPADC_TEMP_SENS_BUFFER_SIZE */

    /* Read the 2 temperature sensor result. */
    if (true == LPADC_GetConvResult(base, &convResultStruct, (uint8_t)index))
    {
        Vbe1 = convResultStruct.convValue >> convResultShift;
        //PRINTF("0x%02X(%u) Shifted:0x%02X\r\n", convResultStruct.convValue, convResultStruct.convValue, Vbe1);
        if (true == LPADC_GetConvResult(base, &convResultStruct, (uint8_t)index))
        {
            Vbe8 = convResultStruct.convValue >> convResultShift;
            //PRINTF("0x%02X(%u) Shifted:0x%02X\r\n", convResultStruct.convValue, convResultStruct.convValue, Vbe8);
            /* Final temperature = A*[alpha*(Vbe8-Vbe1)/(Vbe8 + alpha*(Vbe8-Vbe1))] - B. */
            temperature = parameterSlope * (parameterAlpha * ((float)Vbe8 - (float)Vbe1) /
                                            ((float)Vbe8 + parameterAlpha * ((float)Vbe8 - (float)Vbe1))) -
                          parameterOffset;
        }
    }
    //PRINTF("Temp: %6.3f\r\n", temperature);
    return temperature;
}

Now I did notice from LPC55S69 manual, chapter 39.7.6 Temperature sensor:

4. Depending on the device revision, following Alpha., A and B values are needed to
achieve +/- 4 C temperature accuracy. For device revision 0A: Alpha=9.5, A=770 and
B = 289.4. For device revision 1B: Alpha= 8.5, A=804 and B = 280.

So maybe it indeed is normal that you get +-4C difference while the actual temperature remains the same. SDK given values are something different though.

/* @brief Temperature sensor parameter A (slope). */
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_A (744.6f)
/* @brief Temperature sensor parameter B (offset). */
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_B (313.7f)
/* @brief Temperature sensor parameter Alpha. */
#define FSL_FEATURE_LPADC_TEMP_PARAMETER_ALPHA (11.5f)

 I must say that this is the most unclear temperature measurement that I have ever seen

0 件の賞賛
返信
3,183件の閲覧回数
converse
Senior Contributor V

I wouldn’t expect 1 bit to change it so much, so either the formula, or your interpretation of it, is incorrect. Perhaps you could post your code?

0 件の賞賛
返信
3,195件の閲覧回数
frank_m
Senior Contributor III

Without knowing details about the internal sensor, nor the SDK code, the following thing catched my eye:

0x147E(5246) Shifted:0x28F
0x161B(5659) Shifted:0x2C3
Temp: 27.504

0x1481(5249) Shifted:0x290
0x161D(5661) Shifted:0x2C3
Temp: 23.917

This is just one LSB difference, which would at least be normal for a ADC channel.

0 件の賞賛
返信