写了s3c2440内部ad 中断方式 采集模拟量的代码 结果串口老是打印不出信息 着急啊
大伙帮忙看看 我菜鸟啊 写的可能很多错误 见谅啊
目的:从AIN2采集模拟量 转换后 打印到串口
#define EnableIrq(bit) rINTMSK &= ~(bit)
#define DisableIrq(bit) rINTMSK |= (bit)
#define BIT_ADC (0x1<<31)
static void __irq ADC_ISR(void)
{
int i;
if(rINTPND==BIT_ADC)
{
ClearPending(BIT_ADC);
i= (int)rADCDAT0 & 0x3ff;
Uart_Printf("AIN2=%4d",i);
}
}
__inline void ClearPending(int bit)
{
rSRCPND = bit;
rINTPND = bit;
}
void main(void)
{
ClearPending(BIT_ADC);
pISR_ADC=(U32)ADC_ISR;
EnableIrq(BIT_ADC);
Uart_Printf( "\nADC INPUT Test, press ESC key to exit !\n" ) ;
preScaler = ADC_FREQ;
Uart_Printf("ADC conv. freq. = %dHz\n",preScaler);
preScaler = 50000000/ADC_FREQ -1;
Uart_Printf("PCLK/ADC_FREQ - 1 = %d\n",preScaler);
rADCCON = (1<<14)|(preScaler<<6)|(2<<3); //setup channel
rADCCON|=0x1; //start ADC
while( Uart_GetKey() != ESC_KEY ) ;
DisableIrq(BIT_ADC);
} |