int ADC_Temp(void)
{
UINT8 i;
UINT16 AdcTemp=0;
ADC_InterTSSampInit();
adclen = 0;
PFIC_EnableIRQ( ADC_IRQn );
ADC_StartUp();
while( adclen < 12 );
PFIC_DisableIRQ( ADC_IRQn );
for( i = 2; i < 12; i++ )
AdcTemp += abcBuff[i];
AdcTemp /= 10;
return ADC_GetCurrentTS(AdcTemp);
}
__attribute__((interrupt("WCH-Interrupt-fast")))
__attribute__((sec
tion(".highcode")))
void ADC_IRQHandler( void ) //adc中断服务程序
{
if( ADC_GetITStatus() )
{
ADC_ClearITFlag();
if( adclen < 12 )
{
abcBuff[adclen] = ADC_ReadConverValue();
ADC_StartUp(); // 作用清除中断标志并开启新一轮采样
}
adclen++;
}
}
int ADC_GetCurrentTS( UINT16 ts_v )
{
UINT32 C25_Data[2];
int cal;
FLASH_EEPROM_CMD( CMD_GET_ROM_INFO, ROM_CFG_TMP_25C, C25_Data, 0 );
cal = ( ( (ts_v * 1050) + 2048 ) >> 12 ) + ( 1050 >> 1 );
cal = 25 + ((cal - (int)(C25_Data[0]&0xFFFF))*10/14);
return ( cal );
}
代码如上,温度测出来一直都是8、9度的样子,室温27度,按理说测出来不应该是27度左右吗,不知道是哪里的问题