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__((section(".highcode"))) void?ADC_IRQHandler(?void?)?????????//adc中斷服務(wù)程序 { ??if(?ADC_GetITStatus()?) ??{ ????ADC_ClearITFlag(); ????if(?adclen?<?12?) ????{ ??????abcBuff[adclen]?=?ADC_ReadConverValue(); ??????ADC_StartUp();????????????????//?作用清除中斷標(biāo)志并開(kāi)啟新一輪采樣 ????} ????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?); }
代碼如上,溫度測(cè)出來(lái)一直都是8、9度的樣子,室溫27度,按理說(shuō)測(cè)出來(lái)不應(yīng)該是27度左右嗎,不知道是哪里的問(wèn)題
熱門(mén)產(chǎn)品 :
CH339: 7端口多功能USB HUB控制器芯片