mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
temp: read the on-chip thermal sensor
The chip has a pair of thermal meters and nothing was reading them. This adds a `temp` command that prints the current reading next to the one taken at power-on. The result register at 0x340 splits a 19 bit value across two fields: bits 18:3 live in the low 16 bits, bits 2:0 in bits 18:16, with the sign at bit 18, degrees in 17:10 and a fraction below. The nice part of that layout is that the degrees fall out of a shift of the low half, so the conversion stays 16 bit. The meter comes out of reset latched: the register keeps whatever was measured when the board powered up and then never moves. Four samples 40 s apart came back identical down to the raw ADC, and 0x340 matched the power-on register at 0x350. Clearing bit 2 of the control register at 0x338 during init is what makes it live. Measured on an SWTGW218AS: 58.7 to 59.5 C while running, with the power-on register still showing the 49.2 C it started from. For what it is worth, the scale lines up three ways: the threshold register reads -40 and +125, the slope from warm-up works out at 4450 LSB/C, and the slope between the two meters at 4388 LSB/C. We only read the meter that is up after boot. The other sits in reset with no coefficients, so it would just repeat its power-on value. Costs 231 bytes in BANK2.
This commit is contained in:
1 parent
a62866a93a
commit
48f28ae7ff
3 files changed
+47
No files matched your search
@@ -92,8 +92,18 @@ void static sds_init(void)
|
||||
}
|
||||
|
||||
|
||||
void static tm_init(void)
|
||||
{
|
||||
reg_read_m(RTL837X_TM_CTRL2);
|
||||
sfr_mask_data(0, TM_CTRL2_EN_LATCH, 0);
|
||||
reg_write_m(RTL837X_TM_CTRL2);
|
||||
}
|
||||
|
||||
|
||||
void rtl8373_init(void) __banked
|
||||
{
|
||||
tm_init();
|
||||
|
||||
print_string("\nrtl8373_init called\n");
|
||||
|
||||
// r65d8:3ffbedff R65d8-3ffbedff
|
||||
@@ -191,6 +201,8 @@ void rtl8373_init(void) __banked
|
||||
|
||||
void rtl8372_init(void) __banked
|
||||
{
|
||||
tm_init();
|
||||
|
||||
print_string("\nrtl8372_init called\n");
|
||||
|
||||
sds_init();
|
||||
|
||||
Reference in new issue
Block a user