NXP1768 can communication packet loss ,add judge of tansimit will case program dead

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

NXP1768 can communication packet loss ,add judge of tansimit will case program dead

1,001 Views
sunsky5
Contributor I
0 Kudos
3 Replies

631 Views
Dezheng_Tang
NXP Employee
NXP Employee

Do the following if you want to transmit message. TCS checking in GSR register is important:

while ( !(LPC_CAN1->GSR & (0x1<<3)) );

CANStatus = LPC_CAN1->SR;
if ( CANStatus & 0x00000004 )
{
   LPC_CAN1->TFI  1 = pTxBuf->Frame & 0xC00F0000;
   LPC_CAN1->TID1 = pTxBuf->MsgID;
   LPC_CAN1->TDA1 = pTxBuf->DataA;
   LPC_CAN1->TDB1 = pTxBuf->DataB;
   LPC_CAN1->CMR = 0x21;
   return ( TRUE );
}
else if ( CANStatus & 0x00000400 )
{
   LPC_CAN1->TFI2 = pTxBuf->Frame & 0xC00F0000;
   LPC_CAN1->TID2 = pTxBuf->MsgID;
   LPC_CAN1->TDA2 = pTxBuf->DataA;
   LPC_CAN1->TDB2 = pTxBuf->DataB;
   LPC_CAN1->CMR = 0x41;
   return ( TRUE );
}
else if ( CANStatus & 0x00040000 ) 


   LPC_CAN1->TFI3 = pTxBuf->Frame & 0xC00F0000;
   LPC_CAN1->TID3 = pTxBuf->MsgID;
   LPC_CAN1->TDA3 = pTxBuf->DataA;
   LPC_CAN1->TDB3 = pTxBuf->DataB;
   LPC_CAN1->CMR = 0x81;
   return ( TRUE );
}
return ( FALSE );    // Check why???

0 Kudos

631 Views
sunsky5
Contributor I

Can you see my picture of sending function?  I do not check GSR . But i check the TCS1 TCS2 TCS3 in SR register .I think it has same function with the bit TCS in GSR register.I start the sending of pocket using CMR=0x21,and then i  judge whther finish the sending using statement "while (TCS1==0);".when i check TCS1 in SR register, the program will run to death.do you think my judgement has errors?

0 Kudos

631 Views
Dezheng_Tang
NXP Employee
NXP Employee

Please try the S/W example from NXP website under:

http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-cortex-m-mcus/softwar...

To see if you can get a packet loss error or not first. I don't recall there are any known issues on CAN controller and the same CAN IP has been used on many LPC family MCUs.

0 Kudos