时钟采用内部RC,系统时钟16M,ADC时钟4M,采用连续转换。ADC不取值转换时间3.5us 取值以后转换时间15.6us。转换时间一下子慢了这么多,不知道哪位前辈可以解答一下。
ADC配置文件如下:
#include "ADC.h"
void ADC_init(void)
{
CLK_PCKENR2 |= (1<<4); //enabled ADC1 clock
ADC_CR1 = 0x22; //fADC = fMASTER/4,Continuous conversion mode
ADC_CR2 = 0x08; //Right alignment
ADC_CR3 = 0x00; //Data buffer disabled
ADC_CSR |= 0x04; //ADC channel 4
ADC_CSR |= 0x20; //Interrupt enable for EOC
ADC_TDRL = 0xff;
ADC_CR1 |= 0x01;
ADC_CR1 |= 0x01;
}
uint16_t ADC_GetConversionValue(void)
{
u16 ADC_temp;
ADC_temp = ADC_DRH; //ADC_temp
ADC_temp = ADC_temp<<8; //TEMP左移八位
ADC_temp = ADC_temp+ADC_DRL; //把第八位加上
return ADC_temp;
}
中断函数:
#pragma vector=0x18
__interrupt void ADC1_IRQHandler(void)
{
ADC_CSR &= ~0x80; //清空转换完成标志位EOC
//ADC_Val = ADC_GetConversionValue();
PB5_out = ~PB5_out;
}
注释掉ADC_Val = ADC_GetConversionValue();转换时间是3.5us
去掉注释转换时间为15.6us |