#include /* for EnableInterrupts macro */ #include /* include peripheral declarations */
void Init() { CONFIG1 = 0x09; TSC_TSTOP = 1; TSC_TRST = 1; TSC = 0x46;
TMODH = 0x4b; TMODL = 0x00;
DDRA = 0x10; PTA = 0x00; ADSCR = 0x21; } void delay(uchar t){ uchar i,j; for(i=0;i<=t;i++) for(j=0;j<=t;j++); } void main(void) { EnableInterrupts; /* enable interrupts */ /* include your code here */ Init();
for(;;) { delay(ADR); __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave this function */ }
interrupt 6 void SH_OverFlow_ISR(void){ // EnableInterrupts; /* enable interrupts */ TSC_TOIE = 0; TSC_TOF = 0;
PTA = 0x19;
TSC_TOIE = 1;
} 我这里AD转换是正确的,其实AD转换是不需要你写中断服务程序,系统会自动进入中断服务程序把转换的结果给输入到ADR寄存器里.
[此贴子已经被作者于2006-3-1 16:14:59编辑过]
[此贴子已经被作者于2006-3-1 16:17:41编辑过] |