CAN reciever interrupt flage problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

CAN reciever interrupt flage problem

2,063 次查看
kdn
Contributor III

I am using CAN module of MC9S12XHZ512 microcontroller, I successfully archive transmitting of data from my microcontroller, but problem is that I am able to receive data only one time after that my controller get hang, I think that I have not clear my CAN receiver  interrupt flag, can anyone tell me where I can get CAN receiver interrupt flag in datasheet, I post my interrupt code for CAN below. Do MC9S12XHZ512 compiler support sprintf function.

 

 

#pragma CODE_SEG __NEAR_SEG NON_BANKED

 

 

interrupt void Vcan1RxISR(void)

 

{

     unsigned char  RxBuffer[8],u8Length=8;

   

    unsigned int R,temp;

   

    LCD_Cmd(0x80);

 

     R = CAN1RXDSR0;

    

       

    

         Convert(R);

         LCD_Data(D);

         delay();

         LCD_Data(C);

         delay();

         LCD_Data(B);

         delay();;

         LCD_Data(A);

         delay();

                       

      PORTA = 0xFF;

    

        

      CAN1RFLG_RXF = 1;

}

标签 (1)
0 项奖励
回复
6 回复数

1,801 次查看
iggi
NXP Employee
NXP Employee

The flag should be cleared as following, for example:

CANTFLG = 0x01;  //Clear the TXE flag in the CTFLG register to indicate this buffer is full

/* The following is another method to clear the TXE flag to indicate this buffer is full in assembly language.

Notice that the LDA and STA instructions are used. DO NOT USE THE BSET Instructions.

#asm

LDAA #0x01;

STAA $0x106;

#endasm

*/

Here is the link to an appnote Scalable Controller Area Network (MSCAN) Interrupts which is a bit old, but still usefull for your purpose.

Regards,

iggi

0 项奖励
回复

1,801 次查看
kdn
Contributor III

volatile unsigned int

volatile  means ?

0 项奖励
回复

1,801 次查看
lama
NXP TechSupport
NXP TechSupport
0 项奖励
回复

1,801 次查看
kdn
Contributor III

I am getting this error


error.png

0 项奖励
回复

1,801 次查看
kdn
Contributor III

This code is not working for input capture mode 

#pragma CODE_SEG __NEAR_SEG NON_BANKED

interrupt void  IC0_ISR(void)

{  

  //  new_capture = TC0;   //save the value of input capture register

  

  

    LCD_Cmd(0x80);

 

              PORTA = 0xFF;

       

         t[i]=TC0;

       

          i++;

       

          if(i==2) {

          i=0;

        

       //    6.0742270546073012209196379760675e-8

       

         time_interval=(t[1]-t[0]);

         time_period=(float)(0.0000256* time_interval);

         frequency= 1/time_period;

    

       

     

         sprintf(buffer,"%f",frequency);

         for(j=0;j<4;j++)

         {

         LCD_Data(buffer[j]);

         }

  

}

   TFLG1 = 0x01;       //clear interrupt flag 

}

interrupt void  TOI_ISR(void)

{

 

  

    TFLG2 = 0x80;       //clear interrupt flag

}

unsigned int TM;

/* User includes (#include below this line is not maintained by Processor Expert) */

void main(void)

{

  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */

        LCDIni();

 

//   LCD_Cmd(0x01);

   LCD_Cmd(0x80);

 

   LCD_Data('T');

 

    PPST_PPST0 = 0;  //set pull-up

    PERT_PERT0 = 1;  //enable pull-up  

   TSCR1 = 0xE7;       //enable timer, stop timer during wait and freeze, disable fast flag clear

   TIOS_IOS0 = 0;      //channel 0 as an input capture

    TCTL4 = 0x01;       //capture on rising edge

    TIE_C0I = 0x01;        //enable interrupt on channel 1  

    TSCR2 = 0x80;       //timer overflow interrupt enable, timer prescaler is 0

  for(;;){}

  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

0 项奖励
回复

1,801 次查看
kdn
Contributor III

I have written at end of my code

CANTFLG = 0x01;

but way is different

CAN1RFLG_RXF = 1;

I think  CAN1RFLG_RXF  show CAN receiver FIFO is full , I am looking for CAN receiver interrupt flag.

regard

kushal nandanwar

0 项奖励
回复