Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 28

Thread: Teensy 4.0 Internal Temperature measurement

  1. #1

    Teensy 4.0 Internal Temperature measurement

    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?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,535
    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.

  3. #3
    Quote Originally Posted by MichaelMeissner View Post
    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.

  4. #4
    Senior Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    109
    Quote Originally Posted by MichaelMeissner View Post
    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?

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,535
    Quote Originally Posted by bloodline View Post
    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.

  6. #6
    Senior Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    109
    Quote Originally Posted by MichaelMeissner View Post
    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.

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,543

  8. #8
    Senior Member
    Join Date
    Jan 2014
    Location
    London, UK
    Posts
    109
    Quote Originally Posted by Frank B View Post
    This is fantastic! Hopefully it will spur more activity on the wiki!

  9. #9
    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.

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,543
    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.

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,933
    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".

  12. #12
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,267
    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

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,933
    Quote Originally Posted by tonton81 View Post
    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 85C it is a bit late for overclocked processor as it can go south before it measures that high.

  14. #14
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,267
    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

  15. #15
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,543
    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.

  16. #16
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    Quote Originally Posted by Frank B View Post
    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.

  17. #17
    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?

  18. #18
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,933
    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 60C 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 70C with a heat sink alone.

    Quote Originally Posted by HallMark View Post
    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:
    Quote Originally Posted by defragster View Post
    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 85C 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.

  19. #19
    Quote Originally Posted by defragster View Post
    When running at/under 912 (?) MHz it was stable at temps up to and over 70C 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.

  20. #20
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    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.

  21. #21
    Quote Originally Posted by mjs513 View Post
    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.

  22. #22
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    Quote Originally Posted by HallMark View Post
    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.

  23. #23
    Quote Originally Posted by mjs513 View Post
    Maybe if you provided some additional info on what you are running and what you have connected someone might have some ideas.
    I have 6 ADC chips and 6 Digipots and SD Card.

  24. #24
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,807
    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.

  25. #25
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •