generated from hulk/gd32f4xx_template_cmake_vscode
NTC: add open/short detection (V near rails) instead of bogus temp
This commit is contained in:
+8
-1
@@ -53,7 +53,14 @@ int main(void)
|
||||
static uint16_t temp_report_counter = 0;
|
||||
if (++temp_report_counter >= 100U) { /* 主循环 10ms 一圈 → 1s */
|
||||
temp_report_counter = 0;
|
||||
printf("NTC temp: %.1f C\r\n", ntc_read_temperature());
|
||||
float temp = ntc_read_temperature();
|
||||
if (temp <= -274.0f) {
|
||||
printf("NTC SHORT (PC5 pulled low)\r\n");
|
||||
} else if (temp <= -273.0f) {
|
||||
printf("NTC OPEN (PC5 at VREF, check NTC wiring/solder)\r\n");
|
||||
} else {
|
||||
printf("NTC temp: %.1f C\r\n", temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user