float Get_Temp(int T_Count,int T_Count_Coe) { float Rt; float temp; if(( Averg_Instad[T_Count]<=(int16)UNZR20D)||( Averg_Instad[T_Count]>=(int16)UPZR96D)) { GlbuserRegs.ERCOD2.bit.Thwlos = 1; //temperature sensor error. test20110928 temp= -30; return temp*10; } Averg_Instad[T_Count] = (int32)Averg_Instad[T_Count]*paramet[T_Count_Coe]/1000; //coef uint:1/1000 V1.19 Rt =(float)336027/ Averg_Instad[T_Count]-259.67;//0525 temp=Rt;//0525 return temp*10; } 解释代码各行的作用并说出T_Count代表什么意思
时间: 2024-02-26 09:56:25 浏览: 20
这段代码是一个函数,用于获取温度值。下面是各行代码的解释:
```c
float Get_Temp(int T_Count,int T_Count_Coe) {
```
定义了一个名为 `Get_Temp` 的函数,该函数接受两个整型参数 `T_Count` 和 `T_Count_Coe`,返回一个浮点型值。`T_Count` 代表温度计的编号,`T_Count_Coe` 代表温度计的系数。
```c
float Rt;
float temp;
```
定义了两个浮点型变量 `Rt` 和 `temp`。
```c
if(( Averg_Instad[T_Count]<=(int16)UNZR20D)||( Averg_Instad[T_Count]>=(int16)UPZR96D)) {
GlbuserRegs.ERCOD2.bit.Thwlos = 1; //temperature sensor error. test20110928
temp= -30;
return temp*10;
}
```
如果 `Averg_Instad[T_Count]` 的值小于等于 `UNZR20D` 或者大于等于 `UPZR96D`,则说明温度传感器出现错误,将 `GlbuserRegs.ERCOD2.bit.Thwlos` 设为 1,`temp` 赋值为 -30,返回 `temp` 的值乘以 10。
```c
Averg_Instad[T_Count] = (int32)Averg_Instad[T_Count]*paramet[T_Count_Coe]/1000; //coef uint:1/1000 V1.19
```
将 `Averg_Instad[T_Count]` 乘以 `paramet[T_Count_Coe]` 除以 1000,得到一个新的值,将其赋值给 `Averg_Instad[T_Count]`。
```c
Rt =(float)336027/ Averg_Instad[T_Count]-259.67;
temp=Rt;
```
根据新的 `Averg_Instad[T_Count]` 的值,计算温度值,将其赋值给 `temp`。
```c
return temp*10;
```
将 `temp` 的值乘以 10 并返回。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)