ello,
I am trying to use the on-chip temperature sensor that is internally routed to the adc's channel 0. I found in the data sheet for the lpc54608 we must configure the ADC in single channel burst mode. I have used the adc driver example from the sdk version 2.6, called lpc_adc_burst.
the result after more than 9 conversions is 919. To determine what this equals in mV, i use the equation (Vref_p - Vref_n)/4095 * V_in *1000 = 2.5/4095 * 919*1000.
(with a Vrev_p = 2.5, and Vref_n = 0, and 12 bit resolution)
therefore, the input is 561mV.
Using the graph and tables from the data sheet, this can be fed into an equation based on LLS of:
mV = (-2.04)*temperature + 584 => temperature = (mV - 584)/(-2.04).
this means, in our case with 561mV we have:
temp = (561-584)/(-2.04) = 11.275°C
Considering this is sitting in ambient office temperature, I hardly think this is accurate.
again, please note, this is using the sdk 2.6 version of lpc_adc_burst with only modification to remove the getchar() to initiate the conversions
in main:
...
ADC_Configuration();
/* Enable the interrupt. */
ADC_EnableInterrupts(DEMO_ADC_BASE, kADC_ConvSeqAInterruptEnable);
NVIC_EnableIRQ(DEMO_ADC_IRQ_ID);
PRINTF("Configuration Done.\r\n");
#if defined(FSL_FEATURE_ADC_HAS_CTRL_RESOL) & FSL_FEATURE_ADC_HAS_CTRL_RESOL
PRINTF("ADC Full Range: %d\r\n", g_Adc_12bitFullRange);
#endif /* FSL_FEATURE_ADC_HAS_CTRL_RESOL */
while (1)
{
//GETCHAR();
gAdcConvSeqAIntFlag = false;
/* ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE); */
/* Enable the burst mode and start the conversion. */
ADC_EnableConvSeqABurstMode(DEMO_ADC_BASE, true);
while (!gAdcConvSeqAIntFlag)
{
}
PRINTF("gAdcResultInfoStruct.result = %d\r\n", gAdcResultInfoStruct.result);
PRINTF("gAdcResultInfoStruct.channelNumber = %d\r\n", gAdcResultInfoStruct.channelNumber);
/* PRINTF("gAdcResultInfoStruct.overrunFlag = %d\r\n", gAdcResultInfoStruct.overrunFlag ? 1U : 0U); */
PRINTF("\r\n");
}
}
Hi, Eileen,
I think your code is correct, your computation is correct. Note that you have to wait for 10us after power-up, then use ADC to sample the temperature sensor.
The temperature accuracy is 3.7 degree from -40 to 105 based on data sheet.
Hope it can help you
BR
XiangJun Rong
can i get some guidance please
Hi,
I have rerun the test with slightly different results, I also compared to the newer version of the sdk (2.7) as i'd prefer to use the updated code, but the results there were completely unacceptable. I again have commented out the getchar as this is on a custom board, and these are the results of my testing. in 2.7 version, i had to change the code to use channel 0 rather than channel 4 in the examples.
i have included all code in the zip here, along with more details of the testing. I would prefer to use 2.7 as that is more up to date, but why is it not consistent? Also, why are the results different for 2.6 burst? this is the same board and same code?
thanks,
eileen
sdk 2.6 basic | sdk 2.6 burst | sdk 2.6 int | ||||||||
avg | 535.2564 | 23.89392 | avg | 541.8559 | 20.65886 | avg | 537.4359 | 22.82554 | ||
min | 534.188 | 23.22057 | min | 540.9035 | 20.22792 | min | 536.63 | 22.02351 | ||
max | 536.63 | 24.41763 | max | 542.735 | 21.12572 | max | 539.072 | 23.22057 |
2.7 basic | 2.7 burst | 2.7 int | ||||||||
avg | 468.2112 | 56.7592 | avg | 489.5849 | 46.28193 | avg | 472.619 | 54.59851 | ||
min | 435.8974 | 32.79705 | min | 460.928 | 31.30073 | min | 438.9499 | 33.09632 | ||
max | 517.094 | 72.5993 | max | 520.1465 | 60.32943 | max | 516.4835 | 71.10297 |
sorry, but i really need some direction. i have started using the 2.6 adc burst code just so i can move on, and now, again, i'm getting result in the 915-920 range, translating to 10.95-12.45°. This is using the exact same output file from IAR that is included in the zip folder above. how can i be getting such drastically different results with the exact same image, exact same location, board, etc, etc... ?
just so you are aware, ambient temperature is 21°C
Thank you,
Eileen