
ADC读取出来的数据不知道是不是正确的,,不过也的确有些数字读出来了, 一开始读了一个管脚的电压值,接到3.3上的时候的确是3.3左右。悬空数值不定,接到地就接近0,所以试了一下F407的一个内部ADC的温度传感器,不太确定。 HAL_ADC_Start(&hadc1); for(i = 0 ; i < 10 ; i++) { HAL_ADC_PollForConversion(&hadc1, 10); adcx = HAL_ADC_GetValue(&hadc1); temperate=(float)adcx*(3.3/4096); //µçѹֵ temperate=(temperate-0.76)/0.0025 + 25; //ת»»ÎªÎ¶ÈÖµ result=temperate*=100; //À©´ó100±¶. a+=result; } a /= 10; |
转换为
temperate=(float)(adcx*(3.3/4096))吧!
这样至少让编译器不会出现优先级问题。