Read ATSAMD51 temperatur sensor?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

does anybody know a good source for some example code that demonstrates how to read from the internal temperature sensor of the ATSAMD51? The description in the manual is somewhat unusable for me and Atmel START does not provide any help here...

 

Thanks!

 

This topic has a solution.
Last Edited: Tue. Jul 21, 2020 - 09:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Atmel Start has a TSENS example for SAMD54. You should also find an implementation for Adafruit CircuitPython since there is this example:

https://learn.adafruit.com/adafruit-grand-central/circuitpython-cpu-temp

Implementation should be here (I did not search for it however):

https://github.com/adafruit/circuitpython

/Lars

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I did search for it, it's in ports/atmel-samd/common-hal/microcontroller/Processor.c

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Be aware that SAM D5x/E5x erratum 2.23 states:

 

Both internal temperature sensors, TSENSP and TSENSC, are not supported and should not be used.

 

No idea if this implies they are non-functional and/or wildly inaccurate, but probably best not to rely on them.

 

Steve

Maverick Embedded Technologies Ltd. Home of wAVR and Maven.

wAVR: WiFi AVR ISP/PDI/uPDI Programmer.

Maven: WiFi ARM Cortex-M Debugger/Programmer

https://www.maverick-embedded.co...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Given that it's rather strange they have that TSENS example in atmel start.

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lajon wrote:

Given that it's rather strange they have that TSENS example in atmel start.

 

The only example I found there requires an external temperature sensor connected via I2C?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I only read the description, sure sounds like it is the internal sensor:

This example periodically reads data from two temperature sensors using the ADC driver with the period of a second. Using the two conversion results and the temperature calibration parameters found in the NVM Software Calibration Area, the die temperature T can be calculated. The temperature value in Celsius will be printed to console via the USART driver.

/Lars 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried "Add software component" -> "Middleware" -> "Temperature sensor".  This is linked directly to a I2C instance. Where do you have seen that other description? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's an example for SAME54 Xplained pro.

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, meawhile I got it working for the ATSAMD51 - and it seems the sensors really can'T be used. The measured values for CTAT and PTAT are _below_ of the lower values that are stored in the NVRAM. So the result will always be a temperature close to 0.