MM912F634 input capture problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MM912F634 input capture problem

775 Views
贵阳封
Contributor I

I followed the datasheet carefully and set the value of related register,but when active edge happened ,no input capture interrupt was occurred even the input capture interrupt flag was not detected,my main routine was listed below Thanks for your help。

 

void main(void) {

volatile char rsr, vsr, srr;

/* D2D Init */

  D2DCTL1  = 0x8F;  // IRQ enable, max timeout

  D2DCTL0  = 0x80;  // D2D enable, 4Bit, !Stop in Wait, D2DCLK=BUS

  D2DSTAT0 = 0x80;  // Clear D2D Errors

 

 

  rsr = bRSR;       // Copy/Clear RSR

  vsr = bVSR;       // Copy/Clear VSR

  srr = bSRR;       // Copy/Clear SRR

 

  bCTR0 =  TRIM0;   // Copy Trim Information to Analog Die

  bCTR1 =  TRIM1;

  bCTR2 =  TRIM2;

  bCTR2 =  0x1E;    // Max VREG-Overvoltage Threshold Trim

  bCTR3 =  TRIM3;

 

  bLSCEN = 0x05;    // Enable LS Control

  //bLSCR = 0x00;     // Activate LS

  //bHSCR = 0x00;     // Activate HS

/* -------------------------------------------------------------- */

  //CRGCTL0_OSCEN=1;//内部时钟32K

  //CRGCTL0_BCLKS=1;

  bPTBC1=0X70;//PTB配置为输入口加上拉

  bPTBC2=0;

  bTIOS=0X0F; //IO通道配置输入捕捉

  bACCR=0;

  bTCTL2=0X3F;//上跳沿捕捉

  bTIE=0X07; // 捕捉中断使能

  bTCNT=0; //10ms

 

  bTSCR2=0X80; // 时钟溢出中断使能

  bTSCR1|=0X80; //计时使能/计时器标志清除使能

  EnableInterrupts;

 

  for(;;) {

    M=bPTB;

    N=bTIOS; 

    if(bTFLG1!=0)

    bHSCR=0X01 ;

    U=bTFLG1;

 

  } //for(;;) 

} //main

Original Attachment has been moved to: main.c.zip

Original Attachment has been moved to: Quest_Test.prm.zip

Original Attachment has been moved to: calango.h.zip

Original Attachment has been moved to: MC9S12I32.c.zip

Labels (1)
0 Kudos
5 Replies

543 Views
RadekS
NXP Employee
NXP Employee

I shortly checked your code.

Probably main issue: bTIOS=0X0F; //IO通道配置输入捕

You set all timer channels to output compare mode. Please change TIOS settings to 0x00.

Note: TCNT is free running counter, you can write to this register only in special mode (during debugging).

543 Views
贵阳封
Contributor I

thanks for your reply ,I have modify it as you did but the problem still exist ,the input capture flag still be 0 all time,and can't generate interrupt ,i don't know why。。。。。

0 Kudos

543 Views
RadekS
NXP Employee
NXP Employee

You enabled interrupt (bTIE=0X07; // 捕捉中断使能), unfortunately I didn’t found any interrupt routine for TC0~TC3 in your files. Please define interrupt routines or disable interrupt (you already tested TFLG1 in main loop.)

0 Kudos

543 Views
贵阳封
Contributor I

if(bTFLG1!=0)

    bHSCR=0X01 ;

    U=bTFLG1;

these are the test code for TFLG1, I test it from int U,  if i have no interrupt routine, once interrupt flag was detected the debug software will report error ,but now no error report and the TFLG1 interrupt flag still be 0 all the time even i trigger the PTB0 PTB1 PTB2...........

0 Kudos

543 Views
贵阳封
Contributor I

do you have QQ or MSN,could we communicate online?my QQ 471949374

0 Kudos