cancel
Showing results for 
Search instead for 
Did you mean: 

str710 can problem

jianfeng_2008
Associate
Posted on November 11, 2008 at 23:49

str710 can problem

1 REPLY 1
jianfeng_2008
Associate
Posted on November 11, 2008 at 23:49

I hava designed a product with str710,but the can always crashed. Baud rate is 100K ,about 2 hours start error. It can send ok,but the other mcu dosn't received. I use the ST firmware. It is

u32 CAN_SendMessage(u32 msgobj, canmsg* pCanMsg)

{

while (CAN->sMsgObj[0].CRR & CAN_CRR_BUSY);

/* if (CAN->sMsgObj[0].COMR & CAN_CRQ_BUSY) */

/* return 0; // message interface 0 not free */

CAN->SR &= ~CAN_SR_TXOK;

/* read the Arbitration and Message Control */

CAN->sMsgObj[0].CMR = CAN_CMR_ARB | CAN_CMR_CONTROL;

CAN->sMsgObj[0].CRR = 1 + msgobj;

while (CAN->sMsgObj[0].CRR & CAN_CRR_BUSY);

/* update the contents needed for transmission */

CAN->sMsgObj[0].CMR = CAN_CMR_WRRD

| CAN_CMR_ARB

| CAN_CMR_CONTROL

| CAN_CMR_DATAA

| CAN_CMR_DATAB;

if ((CAN->sMsgObj[0].A2R & CAN_A2R_XTD) == 0)

{

/* standard ID */

CAN->sMsgObj[0].A1R = 0;

CAN->sMsgObj[0].A2R = (CAN->sMsgObj[0].A2R & 0xE000) | STD_FIXED_ID_ARB(pCanMsg->Id);

}

else

{

// extended ID

CAN->sMsgObj[0].A1R = EXT_FIXED_ID_ARB_L(pCanMsg->Id);

CAN->sMsgObj[0].A2R = (CAN->sMsgObj[0].A2R & 0xE000) | EXT_FIXED_ID_ARB_H(pCanMsg->Id);

}

CAN->sMsgObj[0].MCR = (CAN->sMsgObj[0].MCR & 0xFEF0) | CAN_MCR_NEWDAT | CAN_MCR_TXRQST | pCanMsg->Dlc;

CAN->sMsgObj[0].DA1R = ((u16)pCanMsg->Data[1]<Data[0];

CAN->sMsgObj[0].DA2R = ((u16)pCanMsg->Data[3]<Data[2];

CAN->sMsgObj[0].DB1R = ((u16)pCanMsg->Data[5]<Data[4];

CAN->sMsgObj[0].DB2R = ((u16)pCanMsg->Data[7]<Data[6];

CAN->sMsgObj[0].CRR = 1 + msgobj;

////////////////////////

CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);

//////////////////////

return 1;

}

Please help me!