用的是PT100采集外部温度数据,属于模拟信号输入,选用的是P0.7口为模拟输入口。下面是我对ADC寄存器的设置,但是在线调试的时候,ADCH和ADCL里没有数值,不解,求高手指导!万分感谢!
void HalAdcInit (void)
{
#if (HAL_ADC == TRUE)
volatile uint8 tmp;
/*
* After reset, the first ADC reading of the extra conversion always reads GND level.
* We will do a few dummy conversions to bypass this bug.
*/
tmp = ADCL; /* read ADCL,ADCH to clear EOC */
tmp = ADCH
ADCCON3 = HAL_ADC_REF_VOLT | HAL_ADC_DEC_RATE | HAL_ADC_ECHN;//此处将ADCCON3初始化为0x8C。
while ((ADCCON1 & HAL_ADC_EOC) != HAL_ADC_EOC); /* Wait for conversion */
#endif
}
/**************************************************************************************************
* @fn HalAdcRead
*RNDH
* @brief Read the ADC based on given channel and resolution
*
* @param channel - channel where ADC will be read
* @param resolution - the resolution of the value
*
* @return 16 bit value of the ADC in offset binary format.
* Note that the ADC is "bipolar", which means the GND (0V) level is mid-scale.
**************************************************************************************************/