uint8 myApp_ReadTemperature( void ) { #if defined HAL_MCU_CC2430 int tempValue=0;//jia uint16 value;
/* Clear ADC interrupt flag 此中断清除也是原SimpleApp中的*/ ADCIF = 0; //***************************************原来SimpleApp的部分2011-4-21******************************************* // ADCCON3 = (HAL_ADC_REF_125V | HAL_ADC_DEC_128 | HAL_ADC_CHN_VDD3); //注释掉的这些函数是原来的,建议修改的时候保留,这样利于以后搞清楚自己的修改过程,免得新程序没搞好 //原来的也坏掉了,另外建议在注释掉的地方加上时间等标记,这是良好的习惯 /* Wait for the conversion to finish */ // while ( !ADCIF ); /* Get the result */ // value = ADCL; // value |= ((uint16) ADCH) << 8; /* * value now contains measurement of Vdd/3 * 0 indicates 0V and 32767 indicates 1.25V * voltage = (value*3*1.25)/32767 volts * we will multiply by this by 10 to allow units of 0.1 volts */ // value = value >> 6; // divide first by 2^6 // value = value * 37.5; // value = value >> 9; // ...and later by 2^9...to prevent overflow during multiplication //****************************************************************************************************************************** //启动温度转换///jia sendChangeCmd();//jia //读取温度转换值 tempValue = getTmpValue();//jia value=(uint16)tempValue; return value;
用户1696769 2011-5-18 15:46