智能车制作

标题: ATD [打印本页]

作者: fangweidong    时间: 2009-4-19 21:02
标题: ATD
#include <hidef.h>      /* common defines and macros */
#include <MC9S12XS128.h>     /* derivative information */
#include <stdio.h>
#pragma LINK_INFO DERIVATIVE "mc9s12xs128"




void wait() {
  int i,j;
  for(i=0;i<1000;i++)
    for(j=0;j<1000;j++) ;
   
  
}

void AD_Init(void)
{  
  
  ATD0CTL1=0x00;   //7:1-外部触发,65:00-8位精度,4:放电,3210:ch
  ATD0CTL2=0x40;   //禁止外部触发, 中断禁止   
  ATD0CTL3=0xa0;   //右对齐无符号,每次转换4个序列, No FIFO, Freeze模式下继续转   
  ATD0CTL4=0x01;   //765:采样时间为4个AD时钟周期,ATDClock=[BusClock*0.5]/[PRS+1]
  ATD0CTL5=0x30;   //6:0特殊通道禁止,5:1连续转换 ,4:1多通道轮流采样
  ATD0DIEN=0x00;   //禁止数字输入
}
word AD_wData = 0;

void main(void) {
  DisableInterrupts;
   AD_Init();
  DDRB = 0xFF;
  PORTB  = 0x00;
  EnableInterrupts;
  for(;;) { }
}

void interrupt 22 Int_AD0(void)
{
   DisableInterrupts;
   AD_wData = ATD0DR0;  //Read out the Result Register
   PORTB = (byte)AD_wData;
      wait();
   EnableInterrupts;
}
调试时出现  Li1907:Fixup overflow in_Vector_22,to Int_AD0 type 1,at offset 0x0     和Link failed   错误      
哪位大哥,大姐赐教一下。

作者: 379846690    时间: 2009-4-20 21:27
加上"#pragma CODE_SEG __NEAR_SEG NON_BANKED ",就可以编译通过了
作者: fangweidong    时间: 2009-4-22 22:25
谢谢上面那位同志了  
作者: fangweidong    时间: 2009-4-22 22:25
谢谢上面那位同志了  
作者: 断了的弦    时间: 2010-4-21 12:46





欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2