<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC Microcontrollers中的主题 Re: Reading Temperature values from internal sensor</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532679#M10452</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PS: If he means LPC11E67JBD48, than he has a 12bit ADC as well.&lt;/P&gt;&lt;P&gt;(&lt;A href="http://www.nxp.com/documents/data_sheet/LPC11E6X.pdf"&gt;LPC11E6X.pdf&lt;/A&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Feb 2017 13:10:37 GMT</pubDate>
    <dc:creator>johanntaferl</dc:creator>
    <dc:date>2017-02-20T13:10:37Z</dc:date>
    <item>
      <title>Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532675#M10448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by otavioborges on Thu Apr 07 08:04:20 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've trying to get a read from the internal temperature sensor from LPC11eE67JBD48. I've followed the example from LPCOpen "periph_temp". Although, ADC reading seems to be working fine the temperature read is a bit off.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as I understand the ADC reading, that varies form 0x0 to 0xFFF, changes inverted with the temperature over the full range of the uC. Therefore 0x0 would be 105ºC and 0xFFF -40ºC, according to the manual. Is that assumption correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By using this approach I've been getting temperatures close to 80ºC, the IC is not hot to touch, seems close to environment temperature. That's why I've been finding it weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;static uint32_t temp[10];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The snappet of the code I've been using follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
static volatile int tempSample = 0;
static volatile bool tempSeqComplete = false;
static volatile int tempTimer = 1;

static uint32_t temp[10];

uint32_t temp_result;
float temperature;

void ADCA_IRQHandler(void)
{
uint32_t pending;

/* Get pending interrupts */
pending = Chip_ADC_GetFlags(LPC_ADC);

/* Sequence A completion interrupt */
if (pending &amp;amp; ADC_FLAGS_SEQA_INT_MASK) {
if (tempSample &amp;lt; 10) {
/* Save sample */
temp[tempSample] = Chip_ADC_GetDataReg(LPC_ADC, 0);
tempSample++;

if (tempSample &amp;gt;= 10) {
Chip_ADC_StopBurstSequencer(LPC_ADC, ADC_SEQA_IDX);
tempSeqComplete = true;
}
}
}

/* Clear any pending interrupts */
Chip_ADC_ClearFlags(LPC_ADC, pending);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
// Runs every ~10ms
void TIMER32_0_IRQHandler(void){
// Temperature Sequencer
if(tempTimer == 20){
Chip_ADC_StartBurstSequencer(LPC_ADC, ADC_SEQA_IDX);
tempSeqComplete = false;
tempSample = 0;

tempTimer = 0;
}else{
tempTimer++;
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
// Inside main function

// ADC channel 0 - Temperature sensor
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 9, (IOCON_FUNC3 | IOCON_MODE_INACT | IOCON_ADMODE_EN ));

//*****************************************************************************
// Init and Config ADC
//*****************************************************************************
Chip_ADC_Init(LPC_ADC,0);
Chip_ADC_StartCalibration(LPC_ADC);
while(!Chip_ADC_IsCalibrationDone(LPC_ADC)); // Wait until calibration is done
Chip_ADC_SetClockRate(LPC_ADC,ADC_MAX_SAMPLE_RATE);

Chip_ADC_SetupSequencer(LPC_ADC,ADC_SEQA_IDX,(ADC_SEQ_CTRL_CHANSEL(0) | ADC_SEQ_CTRL_MODE_EOS));

// Enable temperature sensor on ADC channel 0
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_TS_PD); // Clear TEMPSENSE_PD
Chip_ADC_SetTrim(LPC_ADC,ADC_TRIM_VRANGE_HIGHV);

Chip_ADC_SetThrLowValue(LPC_ADC, 0, ((1 * 0xFFF) / 4));
Chip_ADC_SetThrHighValue(LPC_ADC, 0, ((3 * 0xFFF) / 4));

/* Clear all pending interrupts */
Chip_ADC_ClearFlags(LPC_ADC, Chip_ADC_GetFlags(LPC_ADC));

Chip_ADC_ClearFlags(LPC_ADC, Chip_ADC_GetFlags(LPC_ADC));

/* Enable ADC sequence A completion interrupt */
Chip_ADC_EnableInt(LPC_ADC, ADC_INTEN_SEQA_ENABLE);

/* Enable ADC NVIC interrupt */
NVIC_EnableIRQ(ADC_A_IRQn);

while(1){
if(tempSeqComplete){
temp_result = ADC_DR_RESULT(temp[9]);
temp_result = 0xFFF - temp_result;
temperature = ((temp_result/4095.0)*145.0)-40.0;
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:33:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532675#M10448</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532676#M10449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by af_bln on Thu Apr 21 04:49:52 MST 2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;As far as I understand the ADC reading, that varies form 0x0 to 0xFFF, changes inverted with the temperature over the full range of the uC. Therefore 0x0 would be &amp;gt;105ºC and 0xFFF -40ºC, according to the manual. Is that assumption correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you are on a wrong way I think your uC has a 10 bit ADC. There is an example how to convert the value to temperature value based on lpc11axx uC example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;adcVal= ADCRead(7);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;voltVal= (adcVal * 3300) / 1024; /* voltage value (in mV)of the ADC is: (ADC/1024)*3.3*1000 mV */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tempVal= (voltVal - 578.34) / (-2.366);/* voltage = -2.366*temperature + 578.34 */&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:33:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532676#M10449</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532677#M10450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;bump&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jun 2016 01:07:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532677#M10450</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-19T01:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532678#M10451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using an LPC11U68 which has a 12 bit ADC and a temperature range from -40 to 105°C. At least the data sheet says so.&lt;/P&gt;&lt;P&gt;I also do get a value of about 80°C.&lt;/P&gt;&lt;P&gt;My calculation was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #7f0055; font-size: small;"&gt;&lt;STRONG&gt;auto&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; temp = 105 - ((&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small;"&gt;int&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;)(rawValue * 145 / rawMax));&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;How do you get the values "-578,34" and "-2,366"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2016 12:02:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532678#M10451</guid>
      <dc:creator>johanntaferl</dc:creator>
      <dc:date>2016-10-10T12:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532679#M10452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PS: If he means LPC11E67JBD48, than he has a 12bit ADC as well.&lt;/P&gt;&lt;P&gt;(&lt;A href="http://www.nxp.com/documents/data_sheet/LPC11E6X.pdf"&gt;LPC11E6X.pdf&lt;/A&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2017 13:10:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532679#M10452</guid>
      <dc:creator>johanntaferl</dc:creator>
      <dc:date>2017-02-20T13:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Temperature values from internal sensor</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532680#M10453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think &lt;A _jive_internal="true" href="https://community.nxp.com/message/878639"&gt;this&lt;/A&gt;&amp;nbsp;answers the question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 10:26:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Reading-Temperature-values-from-internal-sensor/m-p/532680#M10453</guid>
      <dc:creator>johanntaferl</dc:creator>
      <dc:date>2017-02-27T10:26:17Z</dc:date>
    </item>
  </channel>
</rss>

