哪位大虾帮我看看,我为什么进不了AD采样完成中断,是哪个寄存器没写对还是中断函数没写对,急急急!!!谢谢。
void init_ADC(void) {
SIM_SCGC |= SIM_SCGC_ADC_MASK; /* Enable bus clock to ADC module */
ADC_SC1 = 0x4A;
/* AIEN = 1: Interrupts enabled */
/* ADCO = 1: Continuous conversions enabled */
ADC_APCTL1 = 0x00000400; /* Enable ADC channels 10 (PTC2) */
ADC_SC3 = 0x00000005; /* Select ADCACLK, no divide, 10 bit conversion */
/* ADLPC = 0 (default): hi speed config */
/* ADIV = 0 (default): clock rate = input clock/1 */
/* ADLSMP = 0 (default): short sample time */
/* MODE = 1: 10 bit conversion */
/* ADICLK= 1:Bus clock/2 source */
ADC_SC2 =0x00000000; /* SW trigger, default ref pins, no compare */
/* ADTRG = 0 (default): SW Trigger */
/* ACFE = 0 (default): compare function disabled */
/* REFSEL = 0 (default): default ref volt pin pair */
}
中断向量表:
/* The Interrupt Vector Table */
void (* const InterruptVector[])() __attribute__ ((section(".vectortable"))) = {
/* Processor exceptions */
(void(*)(void)) &_estack,
__thumb_startup,
NMI_Handler,
HardFault_Handler,
.
.
.
ADC0_IRQHandler, /* ADC conversion complete interrupt */
.
.
.
};
void ADC0_IRQHandler() __attribute__ ((weak, alias("Default_Handler")));
main(void)
{
init_clks_FEE_40MHz();
init_ADC();
Enable_Interrupt(INT_ADC0); /* Enable ADC0 interrupt */
for(;;) {
a ++;
}
}
void ADC0_IRQHandler(void){ //中断函数
counter++;
}
|