Teensy 4.0 Internal Temperature measurement

Status
Not open for further replies.

HallMark

Well-known member
As in latest Teensyduino 1.51 Temperature shutdown bug get fixed.
My question is how can we measure Teensy internal temperature?
Any direct register access gives the value to be calculated and get temperature value?
 
The Teensy 4 has the following functions:

Code:
void tempmon_init(void);
float tempmonGetTemp(void);
void tempmon_Start();
void tempmon_Stop();
void tempmon_PwrDwn();

TempmonGetTemp returns the temperature in Celsius.
 
The Teensy 4 has the following functions:

Code:
void tempmon_init(void);
float tempmonGetTemp(void);
void tempmon_Start();
void tempmon_Stop();
void tempmon_PwrDwn();

TempmonGetTemp returns the temperature in Celsius.
Thank you MichaelMeissner for these functions.
 
The Teensy 4 has the following functions:

Code:
void tempmon_init(void);
float tempmonGetTemp(void);
void tempmon_Start();
void tempmon_Stop();
void tempmon_PwrDwn();

TempmonGetTemp returns the temperature in Celsius.

Are you able to link to the API document that covers all these awesome little features I don’t know about? ;)
 
Are you able to link to the API document that covers all these awesome little features I don’t know about? ;)

Sometimes there is an API document, sometimes not. For some stuff you need to dig into the IMXRT 1062 data sheet (pages 1221 - 1230 on revision 2 of the reference manual), and the ever popular UTSL (Use the source Luke). In this case (hardware/teensy/avr/cores/teensy4/tempmon.c). Sure it would be better if there was an API document and Paul had plenty of time to update, but he seems to be stretched rather thin at times.

There is a new Teensy Wiki (https://github.com/TeensyUser/doc/wiki) that maybe you can add information as you discover it to help the next person.
 
Sometimes there is an API document, sometimes not. For some stuff you need to dig into the IMXRT 1062 data sheet (pages 1221 - 1230 on revision 2 of the reference manual), and the ever popular UTSL (Use the source Luke). In this case (hardware/teensy/avr/cores/teensy4/tempmon.c). Sure it would be better if there was an API document and Paul had plenty of time to update, but he seems to be stretched rather thin at times.

There is a new Teensy Wiki (https://github.com/TeensyUser/doc/wiki) that maybe you can add information as you discover it to help the next person.

Thanks for the link!

I agree it seems sensible to use a community driven wiki to help improve the documentation rather than taking resources away from board/software development.
 
To confirm, running usleep() will cool down the Teensy?

That way, if we decide to create an overclocked Teensy project (1 GHz...) for surge-performance reasons, we can write idle loops & self-throttling software to prevent instability situations.
 
I don't know what usleep is on a teensy or from what library it comes.

The Teensys have several sleepmodes (There is an Appnote somewhere), but even the easiest, idle, is effective:

Code:
asm volatile ("wfi");
Means, "wait for interrupt" - make it sleep until the next interrupt. On T3.x this will often be the systick. On T4, the systick will _not_ wake up the core. An additional timer, probably the easiest is interval timer, can wake it.
 
Not seen usleep() either. I also missed knowing that "wfi" won't wake on systick like T_3.x's - good info.

Not sure if it is compile at 1GHz or if the speed adjusting "uint32_t set_arm_clock(uint32_t frequency);" in use? That is a best way to scale back and not overheat - combined with "wfi".
 
That be a nice feature to add to watchdog, checking the core's temperature every refresh, and rather than have it panic, you could directly throttle it, reset it, or powerdown, your own way via callback
 
That be a nice feature to add to watchdog, checking the core's temperature every refresh, and rather than have it panic, you could directly throttle it, reset it, or powerdown, your own way via callback

Indeed, that could be a good combination.

There is a HIGH temp _isr() that can be enabled (notes on that in T4 beta thread) - but set at 85°C it is a bit late for overclocked processor as it can go south before it measures that high.
 
Indeed, and doesn't give enough time to tidy up remnant code configuration settings, the panic isr is real, sporatic for a final hit, especially if you want to store stuff on SD before the final blow of reset/power
 
Using inteterrupts sometimes looks like the best solution, but that's not necessarily true, and it can lead to other problems.

Keep it easy and use polling.
 
Using inteterrupts sometimes looks like the best solution, but that's not necessarily true, and it can lead to other problems.

Keep it easy and use polling.

Agreed. You can use the watchdog timer to poll the temperature and if it hits a certain temp you can use the callback to execute what you want the T4 to do. I did test something like this and it does work.
 
One thing that I have noticed.
My Teensy 4.0 when it hits temperature above 77degree C it gets shutoff. I thought there was bug of auto shutoff fixed in latest Teensyduino release.
Is there also any way to setup this High limit something that @defragster mention HIGH temp _isr() or similar things?
 
Is this with overclocking? Anything over/at the indicated 912 MHz PJRC noted indeed requires cooling. A processor sized heat sink helps some ( using a RasPi blobby pin copper with heat tape ) until it can't move more heat - cooling air flow helps more - and to hope to maintain 1GHz a good combination of both perhaps. An image PJRC posted showed a lighter looking bigger fin heat sink for testing, not sure about air flow. Also helps when fully pinned to another board to spread more heat.

With just a heat sink at 960 MHz (IIRC) the T_4 would drop out in the 50 to 60°C range. What tempMon measures may not be the hottest or weakest spot where the raised voltage causes trouble when hot.

When running at/under 912 (?) MHz it was stable at temps up to and over 70°C with a heat sink alone.

One thing that I have noticed.
My Teensy 4.0 when it hits temperature above 77degree C it gets shutoff. I thought there was bug of auto shutoff fixed in latest Teensyduino release.
Is there also any way to setup this High limit something that @defragster mention HIGH temp _isr() or similar things?

In post #13 this was noted - emphasis added:
Indeed, that could be a good combination.

There is a HIGH temp _isr() that can be enabled (notes on that in T4 beta thread) - but set at 85°C it is a bit late for overclocked processor as it can go south before it measures that high.

Increments over 600 MHz using ever higher voltages will shorten the life of the device. I had one quit after a couple of hours when the IDE was 'left' set at 912 MHz or higher for a heat sink attached T_4 when I unpacked a new T_4 with no heat sink. An i2c SSD1306 was being attached and not being aware the extreme OC was set I spent time looking at library code for the failure point while it cooked. It worked a short time after at normal speeds and OC speed with a heat sink before total failure.
 
When running at/under 912 (?) MHz it was stable at temps up to and over 70°C with a heat sink alone.
This is weird then as my Teensy 4.0 run on 600 MHz only I never went above that. Still in debug messages I see that using tempmon functions I am getting temperature above 79 degree.
After mostly after this temperature I see Teensy to get stuck and that is I think because of Panic_Temp_isr.

Heat sink looks must but what you mention here is making me think why my Teensy is going this high Temp even at 600 MHz speed.
 
If you look in tempmon.c you will see the temperatures set for panic and high temp:
Code:
static uint32_t highAlarmTemp   = 85U;
static uint32_t panicAlarmTemp  = 90U;

There is a PR in to change this to 90 and 92 degrees. You can edit the temps in tempmon.c if you would like to do a test and raise the highAlarmTemp. As @defragster mentioned in testing at 600Mhz I don't believe we saw temperatures that high for the T4 and were it shut off. Only when we were overclocking did we see that issue but think another issue stops it.

If you are hitting 79degrees at 600Mhz there may be another issue.
 
If you are hitting 79degrees at 600Mhz there may be another issue.

Yes, That's what I am trying to finding out. As I see temperature is rising to 79 in approx 45-50 runtime. And this is the reason I don't won't to play with the limit as it may damage Teensy board itself.
 
Yes, That's what I am trying to finding out. As I see temperature is rising to 79 in approx 45-50 runtime. And this is the reason I don't won't to play with the limit as it may damage Teensy board itself.
Maybe if you provided some additional info on what you are running and what you have connected someone might have some ideas.
 
I guess first thing I would say is to make check your grounds and make sure they are all connected to common ground. Did I say this right you guys, make sure you have no shorts and make sure you are not putting 5v into the T4 except for Vin :), If they are 5v chips make sure they are on level shifters. Guess the other thing is the T4 have enough to power everything. These are just guesses. Maybe someone else has some ideas.
 
Yes, GND is common for all this. And Yes I have cut down jumper on the back of Teensy as 5V is given to VIN pin.
 
Status
Not open for further replies.
Back
Top