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
/* Enable the interrupt. */
#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 */
gAdcConvSeqAIntFlag = false;
/* ADC_DoSoftwareTriggerConvSeqA(DEMO_ADC_BASE); */
/* Enable the burst mode and start the conversion. */
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); */
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
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?
|sdk 2.6 basic||sdk 2.6 burst||sdk 2.6 int|
|2.7 basic||2.7 burst||2.7 int|
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