AnsweredAssumed Answered

the output of MC9S12G128 is not normal

Question asked by liu feng on Oct 30, 2019
Latest reply on Nov 6, 2019 by Edward Karpicz

i use the mcu which is the MC9S12G128,but when the general timer is enable ,the output of PJ4 is not normal,the voltage ot the PJ4 is 2.6v,however when the Real time is enable ,the output of PJ4 is ok(5V).the same situation is when the PJ4  is configuration as input.

 

 

 

the source code is as follows:

 

 

 

void initialize_TIM(void){
  TSCR1_TFFCA = 1;  // 定时器标志位快速清除
  TSCR1_TEN = 1;    // 定时器使能位. 1=允许定时器正常工作; 0=使主定时器不起作用(包括计数器)
  TIOS  = 0xff;      //指定所有通道为输出比较方式
  TCTL1 = 0x00;        // 后四个通道设置为定时器与输出引脚断开
  TCTL2 = 0x00;     // 前四个通道设置为定时器与输出引脚断开
  TIE   = 0x01;     // 允许通道0定时中断
  TSCR2 = 0x07;        // 预分频系数pr2-pr0:110,时钟周期为4us,
  TFLG1 = 0xff;        // 清除各IC/OC中断标志位
  TFLG2 = 0xff;     // 清除自由定时器中断标志位
}  

 

 

 


//传感器1中断配置
      PTIJ_PTIJ4=0;
      PPSJ |= 0x00;              //极性选择寄存器,选择下降沿;
      PIFJ |= 0x10;                    //对PIFJ的每一位写1来清除标志位;
      PIEJ |= 0x10;              //中断使能寄存器;
      PERJ_PERJ4=1;

 

 

the realtimer source is as follows:

 //16ms real timer
    CPMUINT  &=~(0x80);
    CPMUFLG  &=~(0x80);
    CPMURTI  |= 0x10;     //   0x10
    CPMURTI  |= (16-1);
    //CPMUINT  |=0x80;
    CPMUINT_RTIE = 1;

Outcomes