********************************************************************************
* Detailed Description:
*
* Example shows MCU's temperature measurement with the help of TSENS.
* Calibartion constants for TSENS0 and TSENS1 are read from Test Flash and
* ADC0/ADC1 is set to measure Vbg and TSENS outputs.
* Calculated internal temperature can be desplayed on the Terminal.
*
* EVB connection:
*
* Route LINFlexD_0 TXD/RXD (PB2/PB3) signals to the main board RS-232 transceiver
* Daughtercard:
* J17.11–12 ON .. Connect LINFlexD_0 TXD (PB2) to main board.
* J17.8–9 ON .. Connect LINFlexD_0 RXD (PB3) to main board.
*
* Motherboard
* J14 - SCI_RX ON
* J13 - SCI_TX ON
* J25 - SCI_PWR ON
*
* See results on PC terminal (19200, 8N1, None). You should get following text
* (with different values for sure)
*
* TSENS0/TSENS1 temperature measurement
* press any key to continue...
*
* Calibration constants read from Test Flash
*
* TSENS0 TSENS1
*
* K1 = 429 K1 = -220
* K2 = -5785 K2 = -5767
* K3 = -12800 K3 = -12736
* K4 = 45 K4 = 45
*
* K1 * Vbg_code * 2^-1 + K2 * TSENS_code * 2^3
* T = ------------------------------------------------------------------------- / 4 - 273.15 [degC]
* [K3 * Vbg_code * 2^2 + K4 * TSENS_code] * 2^-10
*
* Vbg0_code = 1502 Vbg1_code = 1502
* TSENS0_code = 2002 TSENS1_code = 1988
*
* TSENS0 temp = 34.57 degC TSENS1 temp = 36.78 degC
*
* ------------------------------------------------------------------------------
* Test HW: MPC57xx
* Maskset: 1N65H
* Target : RAM, internal_FLASH
* Fsys: 200 MHz PLL with 40 MHz crystal reference
* Terminal: 19200, 8N1, None
********************************************************************************
Hi petr,
we download your demo program and run it in our DEMO board. The program seems some problem puzzles me.
When we download the HEX of the example program to 5744pq9 chip, and make it go, we can see the result of MCU temperature calculate is not stable.
below is the screenshot of Lauterbach debugger.
we can see that the MCU temperature oscillates in -10 and 50 degree. it is obviously not correct.
So , can you help me to find the reason of this phenomenon.
Thank you very much.
Any body help me?
I checked it on the MPC5744P EVB and got this result
so hard to say.
What is the full part number you are using?
BR, Petr
Hi Petr,
Thank for your response.
We found that the Vbg0_code and Vbg1_code that acquired by ADC is also not very stable. Can you help me to check your Vbg0_code and Vbg1_code ?
The DEMO program we used is your attachment without changing.
hi Petr,
we have some new discovery.
When we used the CTU to trigger ADC to acquire Vbg0_code or Vbg1_code, the ADC value is not stable.
But when we used register to trigger ADC to acquire Vbg0_code or Vbg1_code, the ADC value seems stabled.
Why?
our CTU trigger ADC period is 100 us, is it too fast?
hi Petr,
i am waiting for your response.
Hi Liu,
I guess, I had the same problem as you. Here is the answer of the support :"...it is necessary to increase the sampling time for band gap due to slow internal capacitance....".
Since, a note is added in the RM, ADC_CTR0 field descriptions, Bit 24-31 INPSAMP :
NOTE: The Bandgap voltage sampling time is controlled by CTR0[INPSAMP]. CTR0[INPSAMP] is also
used for the external channel sample time. When the user software needs to sample the
Bandgap voltage, it must change the CTR0[INPSAMP] value to allow for a longer time while the
Bandgap is being sampled, then change its value back to the normal value for sampling external
channels.
Best regards,
Pat
hi pat,
thanks for your response.
now i understand why i should change the CTR0[INPSAMP] value to allow for a longer time while the Bandgap is being sampled.
can you give me a suggest value of CTR0[INPSAMP] for sampling the Bandgap? Because i hope the value is not very big. the big value of CTR0[INPSAMP] will effect more of my basic software scheduler.
Hi liu,
A value of 0x50 has been suggested by the design team, which is strongly custom hardware/PCB dependent like noise on voltage reference, etc... So, be careful.
Best regards,
Pat
Hi,
Maybe you need modify the code:
============================================================
// TSEN1 temperature calculation
ADC_1.MCR.B.NSTART = 1; /* Trigger normal conversions for ADC1 */
while(ADC_1.CDR[15].B.VALID != 1) {}; /* Wait for last scan to complete */
Vbg1_Code = ADC_1.CDR[10].B.CDATA;
TSENS1_Code = ADC_1.CDR[15].B.CDATA;
temp1 = K1_1 * Vbg1_Code / 2 + K2_1 * TSENS1_Code * 8;
temp2 = (K3_1 * Vbg1_Code * 4 + K4_1 * TSENS1_Code) * 0.0009765625;
TSENS1_T = temp1 / temp2 / 4 - 273.15;
============================================================
Best regards,